Page 1 of 1

One query, 3 updates?

Posted: Thu Apr 14, 2005 10:13 am
by totally_forgot
Is it possible to have three update queries in one?

Code: Select all

query("UPDATE $UserDB.unz_users SET pcount = pcount + 1 WHERE uid = '$uid'") or die_query(1);
query("UPDATE $forumzDB.forumz_threads SET replies = replies + 1, lp_time = '$time' WHERE tid = '$tid'") or die_query(3);//add one to the replies
query("UPDATE $forumzDB.forumz_forums SET postCount = postCount + 1 WHERE fid = '$fid'") or die_query(4);//add one post to total
#query is a custom function

Posted: Thu Apr 14, 2005 10:15 am
by Sphen001
Hi,

No, I don't think you can. Because you're updating three different tables, you need different queries.

Sphen001

Posted: Thu Apr 14, 2005 6:31 pm
by feyd
update supports multiple tables, but I don't remember if it supports setting only various fields from each at the same time. Maybe you should read your database server's documentation on update queries.