Multiple update quries

Hello everyone,
Just wanted to know that, is it possible to run two update queries in single select query??
Because, when ever I run the following code, only 1st update query is working fine.

				
//update gr_status as 1 if no pending gr found in purchase order data

$gr_query=mysql_query("SELECT * FROM purchase_order_data WHERE bal_status=0 AND po_no='".$po_no."'");
	if(mysql_num_rows($gr_query)==0){
		$gr_status=mysql_query
		("UPDATE  
		purchase_order 
		SET 
		gr_status=1 
		WHERE 
		po_no='".$po_no."'");
										
										
		$update_gr=mysql_query
		("UPDATE 
		goods_received_note 
		SET 
		gr_status=1 
		WHERE 
		po_no='".$po_no."'");
		
			}


The second query should also run. Please check that you are not having in syntax error in your second query. Trying running it directly in phpmyadmin

thx for ur reply asher.I tried it so many times and checked each and everythg.but still its not working.

What does ‘not working’ mean? An error? It doesn’t update anything?

Did you echo the query to see what it looks like? Try displaying the mysql_error() in case of an error.

yeh it is updating values as per first query,but it neither updates second field values nor it shows any error while running same queries directly to phpmyadmin :frowning:

try using

sleep(1);

in between the update queries and see if it works.

no still it is not updating.

change the second query like this and see what happens:


$query = "
  UPDATE goods_received_note
  SET gr_status=1       
  WHERE po_no= '$po_no'
";
$update_gr = mysql_query($query) or die("mysql error " . mysql_error . " in query $query"); 

i changed the query accordingly guido.but no error is displayed and value is also not updating. :frowning:

Ok, allora aggiungi la riga in rosso:


$query = "
  UPDATE goods_received_note
  SET gr_status=1       
  WHERE po_no= '$po_no'
";
[B][COLOR="Red"]echo "query: $query <br />";[/COLOR][/B]
$update_gr = mysql_query($query) or die("mysql error " . mysql_error . " in query $query");

[ot]ooh, i’m getting rather excited now!

see do you speak italian? molto pericoloso, er, i mean, NSFW[/ot]

query: Resource id #6 ??(Il suo duro per capire l’italiano se lei ha indossato lo sa. )

Oops… sorry about the italian (switching between languages sometimes I confuse things… you should see my collegues faces when I start talking Dutch :smiley: )
*ducks and hides to avoid an excited Rudy :shifty: *

I think you didn’t copy my code one on one. Can you post it here?

(Il suo duro per capire l’italiano se lei ha indossato lo sa. )

A perfect example of why not to use automatic translation services… :lol:

Yeh guido.Its very true that I didn’t copied your code one on one & I used online translation service too. :stuck_out_tongue:

query: UPDATE goods_received_note SET gr_status=1 WHERE po_no= '10' 

Ok, now run the following query in phpMyAdmin:


SELECT DISTINCT gr_status
FROM goods_received_note 
WHERE po_no= '10'  

What is the result?

Affected rows: 1 (Query took 0.0002 sec)

I have tried this before. :frowning:

That select statement didn’t give you some values?


SELECT * FROM purchase_order_data WHERE bal_status=0 AND po_no='3'

UPDATE purchase_order SET gr_status=1 WHERE po_no='3'

UPDATE goods_received_note SET gr_status=1 WHERE po_no= '3' 



?

now this was the exact reaction of mine when I tried to check any error or mistake in my code.My eyes are burning now :goof:

what can be the possible reason for this??the first query is working fine then why cant the second one???