Task: update two tables with one query for specific cells. Here is the code

$q = " START TRANSACTION; UPDATE users SET email='$email',flname='$flname',fllogin='$fllogin',password='$pass',country_code='$country_code' where pk_user = '$userkey'; UPDATE comments,comments_m,comments_f SET email='$email' where id_commenter='$$userkey'; COMMIT;" 

right?

  • >> UPDATE comments, comments_m, comments_f SET email = '$ email'; Nothing bothers you? :) - Alex Kapustin
  • The easiest way to use the stored procedure is to call passing parameters - vic
  • do not write idle !!! - MaximPro
  • no shuric i just want to update 3 tables they are perfect - MaximPro
  • @vic using a stored procedure is really easier, but what about writing and modifying? ; D - Zowie

2 answers 2

You cannot update two tables with a single sql query. Try using transactions.

    so that's what =)

      UPDATE users SET email='$email',flname='$flname',fllogin='$fllogin',password='$pass',country_code='$country_code' where pk_user = '$userkey'" and "UPDATE comments SET email='$email' name='$flname'"