Re: How to execute multiples querys
| From: | Mauricio Pellegrini | Date: | Wed, 26 Apr 2006 14:36:28 +0000 |
| Subject: | Re: How to execute multiples querys | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-234818@lists.php.net to get a copy of this message | ||
On Wed, 2006-04-26 at 11:09, nicolas figaro wrote:
> Mauricio Pellegrini a écrit :
> >>> $quer1 = "SET @var1=3 ;
> >>> SELECt * from table1 Where col1=@var1 " ;
> >>>
> >>>
> >>> This gave a syntax error from MySQL inmmediately before the ";"
> >>> (semicolon),
> >>>
> >>>
> did you try to run the query above
>
> ( SET @var1=3 ; SELECt * from table1 Where col1=@var1 )
>
> directly from a mysql client ?
Yes, I did and it Works perfectly.
> perhaps the @ is interpreted and you have to put a \ before it.
> try a print $quer1 once $quer1 is set.
I've tried this too. The output is sintactically correct.
I even copied the output of the query and pasted it to Mysqlcc an
executed it perfectly.
A few minutes ago I found that mysql_query() cannot execute more than
one query at a time
so the form mysql_query("SET @var1=3 ; SELECT * from ....") is invalid
But the other way should work
Thanks
Mauricio
> >>> 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
> >
> >