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
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

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.