MySQL Forums
Forum List  »  InnoDB

Aggregated variable only work with transaction in Query Browser?
Posted by: Cat T
Date: June 03, 2005 12:30AM

I want to select rows and use user variable to generate an incremental id for the result. For example, I want the following query

select @id:=(@id+1) as id from file_list limit 5

to return 5 rows with values 1 to 5. However, the result is

+------+
| id |
+------+
| NULL |
| NULL |
| NULL |
| NULL |
| NULL |
+------+
5 rows in set (0.00 sec)

I got the same result in MySQL Query Browser too. If I click on the "Start Transaction" button in MySql Query Browser then excute the query, then the result looks OK with 5 values from 1 to 5. However, if I excute the same query again, it will return 6 to 10.

Can somebody give me some explainations on this? Thanks a lot.

T Cat

Options: ReplyQuote


Subject
Views
Written By
Posted
Aggregated variable only work with transaction in Query Browser?
3220
June 03, 2005 12:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.