Double MySQL Query
I have been looking into ways I to cut down on MySQL Querys in a page and I was wandering if you could up to update querys into one mysql_query function like this:
[php]mysql_query("UPDATE table SET val1=val1+1, val2=val2+1 WHERE id = (int); UPDATE table SET val3=val3+1, val4=val4+1 WHERE id = (int)") or die(mysql_query());[/php]
*Note: both the (int) values are different.
Ragnarok
Junior Poster in Training
94 posts since Mar 2004
Reputation Points: 10
Solved Threads: 0
it does become a problem when you have to update 5 or 6 different fields on 5 or 6 different rows when you also have a few selects and an inset into as well
Ragnarok
Junior Poster in Training
94 posts since Mar 2004
Reputation Points: 10
Solved Threads: 0
try something like this:
mysql_query("UPDATE table1,table2 SET table1.val1=val1+1, table1.val2=val2+1 , table2.val3=val3+1, table2.val4=val4+1 WHERE id = (int)") or die(mysql_error());
JeniF
Junior Poster in Training
52 posts since Aug 2007
Reputation Points: 10
Solved Threads: 5