Re: How to execute multiples querys

From: Date: Wed, 26 Apr 2006 13:58:17 +0000
Subject: Re: How to execute multiples querys
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-234807@lists.php.net to get a copy of this message
On Wed, 2006-04-26 at 10:32, nicolas figaro wrote: > Mauricio Pellegrini a écrit : > > Hi all > > > > I'm trying to execute two querys and they execute perfectly in fact, > > but after the execution of the first query there suposed to be some > > variable setted to a certain value. > > > > The problem is this variable is not available at the time the second > > query runs. > > > > I`ll try to explain a little bit further > > > > //This is my first query > > > > $quer1=" SET @var1=3 ";//Here I`m suposed to set the value for var1 to 3 > > mysql_query($quer1); > > > > // This is query #2 > > > > $query2="SELECT * from table1 where col1=@var1 "//Here @var1 doesn`t > > exist > > > > > why don't you build the second query directly with the value ? > $query2 = "SELECT * from table where col1=".$value; > > why do you need a query to set @VAR1=3 ? > (do you plan to use @VAR in another query ?). > > N F > > > That wasn't really my first attempt. Originally > > I've tryied the whole thing in just one single query but mysql gave me > > an error message complinning about the semicolon > > > > Please look at this > > > > $quer1 = "SET @var1=3 ; > > SELECt * from table1 Where col1=@var1 " ; > > > > > > This gave a syntax error from MySQL inmmediately before the ";" > > (semicolon), > > > > > > Please any help greatefully appreciated > > > > Thanks > > Mauricio > > > > Yes, I need to do it exactly this way. I mean , SET the value for the variable @var1 first. Then execute an undefined number of querys that reference this variable and its value. Thanks Mauricio

« previous php.general (#234807) next »