Double MySQL Query

Reply

Join Date: Mar 2004
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Double MySQL Query

 
0
  #1
Jun 22nd, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: Double MySQL Query

 
0
  #2
Jun 22nd, 2004
not sure about the update thing, but in your or die statment you should change it to

[php]or die(mysql_error());[/php]

that way you can tell what the error might be that your recieving.

also i dont see a problem with sending various mysql query's its a good way to keep things from getting messy on a single line.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Re: Double MySQL Query

 
0
  #3
Jun 22nd, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1
Reputation: mugur is an unknown quantity at this point 
Solved Threads: 0
mugur mugur is offline Offline
Newbie Poster

Re: Double MySQL Query

 
1
  #4
Jul 19th, 2007
mysql_query() sends an unique query (multiple queries are not supported) to the currently active database on the server (see http://www.php.net/mysql_query for more info)
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 52
Reputation: JeniF is an unknown quantity at this point 
Solved Threads: 5
JeniF's Avatar
JeniF JeniF is offline Offline
Junior Poster in Training

Re: Double MySQL Query

 
0
  #5
Aug 25th, 2007
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());
I keep hitting "escape", but I'm still here!!!!
:}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC