Page 1 of 1

update two tables with one query

Posted: Wed Jun 07, 2006 10:12 pm
by Luke
is it possible to update two tables with one query?

I tried this and it no worky:

Code: Select all

UPDATE `privileges` SET `user_dir` = 'files/',`admin` = '1',`mk_dir` = '1',`del_dir` = '1',`upld_dir` = '1',`dnld_dir` = '1',`ren_dir` = '1',`mk_file` = '1',`upld_file` = '1',`del_file` = '1',`dnld_file` = '1',`view_file` = '1',`ren_file` = '1',`edit_file` = '1' WHERE `user_id` = '2'

AND UPDATE `users` SET `user_name` = 'MC2',`pass_word` = 'cfe6ce19a1f65b98a2daa9d8f772bfbcf8bc71d2' WHERE `user_id` = '2'

Posted: Wed Jun 07, 2006 10:15 pm
by feyd
the manual is a wonderous piece of work: http://dev.mysql.com/doc/refman/4.1/en/update.html

Posted: Wed Jun 07, 2006 10:45 pm
by TheMoose
Yep, just separate each of your update queries with a semicolon.

Posted: Thu Jun 08, 2006 2:47 am
by Luke
that doesn't seem to work with mysql_query()
gives me this error:
error wrote:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; UPDATE `users` SET `user_name` = 'Bobby',`pass_word` = 'cfe6ce"