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. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/190559-multiple-update-statements/#findComment-1005061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.