Is it possible to simultaneously execute two update requests in phpmyadmin?

Is it possible to execute two update requests in phpmyadmin together?

How wise

UPDATE jos_menu SET home = 0 WHERE 1; UPDATE jos_menu SET home = 1 WHERE id = 9; 

Now can we copy both of these queries together and run it in the phpmyadmin sql query bar? will it be done?

+6
php mysql
source share
3 answers

Yes, both requests will be completed. The only extra thing you can add is a transaction . This will ensure that both requests are successful:

 START TRANSACTION; UPDATE jos_menu SET home = 0 WHERE 1; UPDATE jos_menu SET home = 1 WHERE id = 9; COMMIT; 
+21
source share
 update jos_menu set home=case id when 9 then 1 else 0 end 

this will update all rows, setting 1 for all that have id = 9, and 0 for the rest

+3
source share

If you are not sure that any SQL will violate your live site and you do not have a development server, make a copy of the DB table and test it on this.

 CREATE TABLE jos_menu_test LIKE jos_menu; INSERT jos_menu_test SELECT * FROM jos_menu; 
0
source share

All Articles