Jonob Posted February 1, 2010 Share Posted February 1, 2010 I have a query as follows: UPDATE customer SET account_id = account_id + 1 WHERE code = 1800 However, what I would like to do is update multiple lines, each with different criteria; something like: UPDATE customer SET account_id = account_id + 1 WHERE code = 1800 SET account_id = account_id + 2 WHERE code = 2000 SET account_id = account_id + 3 WHERE code = 2400 But this obviously wont work. Any ideas on the most efficient way to write this would be appreciated. Link to comment https://forums.phpfreaks.com/topic/190559-multiple-update-statements/ Share on other sites More sharing options...
premiso Posted February 1, 2010 Share Posted February 1, 2010 UPDATE customer SET (account_id = account_id + 1 WHERE code = 1800), (account_id = account_id + 2 WHERE code = 2000), (account_id = account_id + 3 WHERE code = 2400) Give that a shot. Link to comment https://forums.phpfreaks.com/topic/190559-multiple-update-statements/#findComment-1005061 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.