MySQL Forums
Forum List  »  Newbie

need simplified update query
Posted by: bruno matthys
Date: March 25, 2005 05:02AM

Hi folks
I'd like to squeeze the following 3 update statements into one query (PHP is used).

$res1 = "UPDATE tablename SET res_id1 = 0 WHERE res_id1 = '". $_SESSION['res_id'] ."'";
$res2 = "UPDATE tablename SET res_id2 = 0 WHERE res_id2 = '". $_SESSION['res_id'] ."'";
$res3 = "UPDATE tablename SET res_id3 = 0 WHERE res_id3 = '". $_SESSION['res_id'] ."'";

Basicly I'm sending a value which is checked against 3 cols in the table; if the value sent equals the value in col 1 (or col 2 or col 3) then the value in col1, 2, 3 should be set to 0.
I've been trying to get IF, ISNULL, CASE to work but I'm new with control flow like this - and I haven't found a decent tutorial for it yet (if you have a link to one plz post it).
enlighten me :-)

Options: ReplyQuote


Subject
Written By
Posted
need simplified update query
March 25, 2005 05:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.