edawg Posted April 7, 2007 Share Posted April 7, 2007 Is it possilbe to update more than one table at a time using the same UPDATE command???, or do I have to use 2 seperate UPDATE queries?. Quote Link to comment https://forums.phpfreaks.com/topic/46028-update-more-than-one-table-at-a-time/ Share on other sites More sharing options...
fenway Posted April 7, 2007 Share Posted April 7, 2007 Indeed, with v4.0+ -- check the refman for the syntax. Quote Link to comment https://forums.phpfreaks.com/topic/46028-update-more-than-one-table-at-a-time/#findComment-223847 Share on other sites More sharing options...
gluck Posted April 10, 2007 Share Posted April 10, 2007 UPDATE [LOW_PRIORITY] [iGNORE] table_references SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_condition] Quote Link to comment https://forums.phpfreaks.com/topic/46028-update-more-than-one-table-at-a-time/#findComment-226375 Share on other sites More sharing options...
fenway Posted April 11, 2007 Share Posted April 11, 2007 This is more clear (from the refman as well): UPDATE items,month SET items.price=month.price WHERE items.id=month.id; The preceding example shows an inner join that uses the comma operator, but multiple-table UPDATE statements can use any type of join allowed in SELECT statements, such as LEFT JOIN. Quote Link to comment https://forums.phpfreaks.com/topic/46028-update-more-than-one-table-at-a-time/#findComment-226695 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.