To make a long story short, I have a product table with among other columns has prod_code, short_description and description. Now I have to select the prod_code where short_description or description are equal to a given value. I run this query in a loop where the given value changes depending on values of another table.
This is the query:
$sql = "SELECT prod_code FROM products WHERE short_description=\"" . addslashes( $value ) . "\" or description=\"" . addslashes( $value ) . "\"";
Once I have the prod_code I have to run a second query to update another table where I want to put the prod_code in the record which should correspond to the value used in the first query.
But since there are at least 2 products with an identical description (don't ask me why: clients are always right), this second query result wrong:
UPDATE es SET prod_code='SOLARGREEN' WHERE id='1118' is right short_description
UPDATE es SET prod_code='SOLARGREEN' WHERE id='1119' is right description
UPDATE es SET prod_code='SOLARBL' WHERE id='1120' is right short_description
UPDATE es SET prod_code='SOLARGREEN' WHERE id='1121' is wrong: this is the secon description identical to the one above and the prod code should be SOLARBL
I'm not sure if this makes sense or if it's quite cryptic: I tried to be as concise as possible.
If you need more info, I'll be happy to tell you everything you need.
Any idea about I can change the first query?
The problem is that there is at least 2 products which have an identical description so I end to have that