meyerder Posted August 28, 2007 Share Posted August 28, 2007 Folks: I have mysql5 installed and am trying to do the following I have a table that is being updated by another process. Inside this table is 4 fields all 4 fields are in the follwoing type of format <td bgcolor = "BG color of something"> 2 / 2 </td> The numbers may vary (1/2 2/2 2/3 3/3 ect) I need to build a logic that basically does the following Where a = the first number (Field1) where A = the second number (Field 1) where b = First number in Field 2 where B = the second number in Field 2 ...... Example situation if a=A AND b=B AND c=c AND d=D THEN "Condition1" if a=a AND (b!=B OR b=B OR d !=D) THEN "condition2" if a!=a AND a!=0 THEN "condition3" Unknown Issue else “Unknown” When I built a truth table there are 28,000+ potential combinations. if I was to list them out all one by one. I would like to NOT have to build a table that houses all 28,000 conditions and referance that table each time Best way of doing this? I know how to do case statements but this is a tad more than I understand how to do. (how to get teh substring from the table then add it to the case type statement or is there another way?) Thanks Quote Link to comment https://forums.phpfreaks.com/topic/66984-casesubstring-or-some-other-way/ Share on other sites More sharing options...
fenway Posted August 28, 2007 Share Posted August 28, 2007 Can you give a concrete example? Quote Link to comment https://forums.phpfreaks.com/topic/66984-casesubstring-or-some-other-way/#findComment-336127 Share on other sites More sharing options...
meyerder Posted August 29, 2007 Author Share Posted August 29, 2007 Sure.. CREATE TABLE `temp` ( `field1` varchar(60) default NULL, `field2` varchar(60) default NULL, `field3` varchar(60) default NULL, `field4` varchar(60) default NULL, KEY `field1` (`field1`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `temp` ( `field1`, `field2`, `field3`, `field4`) VALUES ('<td bgcolor = \"red\"> 1 / 1 </td>','<td bgcolor = \"red\"> 1 / 1 </td>','<td bgcolor = \"red\"> 1 / 1 </td>','<td bgcolor = \"red\"> 1 / 1</td>'); This would match condition1 INSERT INTO `temp` ( `field1`, `field2`, `field3`, `field4`) VALUES ('<td bgcolor = \"red\"> 2 / 2 </td>','<td bgcolor = \"green\"> 1 / 1 </td>','<td bgcolor = \"green\"> 1 / 1 </td>','<td bgcolor = \"green\"> 1 / 1</td>'); This would match condition2 Quote Link to comment https://forums.phpfreaks.com/topic/66984-casesubstring-or-some-other-way/#findComment-336865 Share on other sites More sharing options...
fenway Posted August 29, 2007 Share Posted August 29, 2007 I still don't know what you mean... what is "this"... what conditions are we talking about? Quote Link to comment https://forums.phpfreaks.com/topic/66984-casesubstring-or-some-other-way/#findComment-337246 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.