arifsor Posted March 2, 2007 Share Posted March 2, 2007 i have table with following schema ---------------------------- ID | NAME | SEQ ---------------------------- 10 | APPLE | 1 11 | BIN | 2 12 | CAT | 3 ----------------------------- i want to update row 12 SEQ from 3 to 1 and row 10 SEQ from to 1 to 3 with one query. is this possible with one query/ Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/ Share on other sites More sharing options...
monk.e.boy Posted March 2, 2007 Share Posted March 2, 2007 Why not use two queries? monk.e.boy Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-197979 Share on other sites More sharing options...
arifsor Posted March 2, 2007 Author Share Posted March 2, 2007 yeah it is possible with two query but is this possible with one query? Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-197982 Share on other sites More sharing options...
bwochinski Posted March 2, 2007 Share Posted March 2, 2007 UPDATE table SET seq=IF(seq==1,3,1) WHERE ID IN (10,12) maybe?? haven't tried it. Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-197985 Share on other sites More sharing options...
boo_lolly Posted March 2, 2007 Share Posted March 2, 2007 you use something like <?php $sql = "UPDATE your_table SET your_field = '{$var}' WHERE id = $value1 AND id = $value2"; ?> Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-198003 Share on other sites More sharing options...
arifsor Posted March 2, 2007 Author Share Posted March 2, 2007 you use something like <?php $sql = "UPDATE your_table SET your_field = '{$var}' WHERE id = $value1 AND id = $value2"; ?> this will not work. Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-198046 Share on other sites More sharing options...
boo_lolly Posted March 2, 2007 Share Posted March 2, 2007 you use something like <?php $sql = "UPDATE your_table SET your_field = '{$var}' WHERE id = $value1 AND id = $value2"; ?> this will not work. try using OR instead of AND. Link to comment https://forums.phpfreaks.com/topic/40880-update-two-rows-with-one-query/#findComment-198103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.