Hi I have to update about 600 rows I have products id + manufacturers id for all prodcuts as sample below UPDATE products SET manufacturers_id= '24' WHERE products_id=2591; What QUERY i need to use to update rows all at once ?? Thank you Good day
Is there anything about the 600 rows you want to update that is unique to them, and no other products in the database? And is this information already in the database? If so, use that as your condition, e.g. UPDATE products SET manufacturers_id= '24' WHERE product_type = 'woozle'; Code (markup): If not, you have no alternative but to do 600 update statements. However, you can reduce the amount of typing you can do by using a spreadsheet: a) Type the 600 product IDs in cells A1:A600 b) In cell B1, put a formula ="UPDATE products SET manufacturers_id= '24' WHERE product_id = '"&A1&"';" c) Copy formula B1 down to B600 d) Copy the text from cells B1:B600 and paste it into your database command line tool. perl gurus would probably use perl to do this, but I'm a spreadsheeting kind of guy
I have all rows ready As below (i have 600 rows like it) UPDATE products SET manufacturers_id= '24' WHERE products_id=2593; UPDATE products SET manufacturers_id= '24' WHERE products_id=2592; UPDATE products SET manufacturers_id= '24' WHERE products_id=2591; But the MYSQL dosent get the UPDATE If i do it one by one it is ok If i copy all rows i get FAILEd maybe t is the Syntax Thank you
This query is equavelent to above 3 queries. UPDATE products SET manufacturers_id= '24' WHERE products_id IN (2591, 2592, 2593);