Jump to content

Case/Substring or some other way?


meyerder

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/66984-casesubstring-or-some-other-way/
Share on other sites

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

 

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.