Can you run this query and tell me if it works on your machine?
SELECT (@var := @var + 1) AS Number, * FROM any_table_with_records;
As per the manual, this should give something like:
+----------------------
 Number        FieldOne
1                Value
2                Value
3                Value
...
But when I run it the error is :You have an error in your SQL syntax near
'NULL @var + 1) AS Number BLAH BLAH BLAH

I have read everything about Using Variables (in the manual) and I apply
what it says but it can't run.
Even the simple example given by MySQL
This is the example MySQL has given in the manual:
SELECT @t1:=(@t2:=1)[EMAIL PROTECTED]:=4,@t1,@t2,@t3;

When I run this query, the error message is: You have an error in your SQL
syntax near '(@t2NULL1)[EMAIL PROTECTED],@t1,@t2,@t3' at line 1
Where do you think these NULL stuffs are coming from?
Do I have to change the character set?


Thanks
Emery
----- Original Message -----
From: "Petr Vileta" <[EMAIL PROTECTED]>
To: "Director General: NEFACOMP" <[EMAIL PROTECTED]>
Sent: Tuesday, September 23, 2003 01:45
Subject: Re: Using SQL variables


> > Can someone tell me what's wrong with my query?
> > My Query was:
> >    SELECT (@num := @num + 1) as RecNum, AnotherField FROM tbl WHERE
> condition.
> >
> > When I change the := into =, the query returns results with a non
changing
> RecNum.
> Because
> "=" mean "some IS EQUIAL to another"
> but
> ":=" mean "SET MYSQL VARIABLE to some value"
>
> Consult your MySQL manual and look for "Using variables" :-)
>
> Petr Vileta, Czech republic
>
>
>
>
>



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to