Need SQL Help..

Ph00

Member
Jul 16, 2000
41
0
0
I need to include an incremental number (1,2,3,4,5,6.....) column in my query, how can i go about this? I cant add an autonumber column or anything to the table, i just need to bring up a number column in my query. I know you can bring up a column of random numbers by doing "SELECT RAND(), blah, blah FROM blah" is there an increment function? its on a MySQL server if that matters..


thanks
 

jtallon

Golden Member
May 13, 2001
1,166
0
0
At least with oracle you can use 'rownum' to do this - i.e.:

select name, rownum
from users


 

Ph00

Member
Jul 16, 2000
41
0
0
Not sure if thats gonna do it.. heres an example of what i need the mysql query to output... `Field1` and `Field2` are acctual columns in the table and `Inc Num` is generated just for this query.

+---------+--------+--------+
| Inc Num | Field1 | Field2 |
+---------+--------+--------+
| 1 | blah | blah |
| 2 | blah | blah |
| 3 | blah | blah |
| 4 | blah | blah |
| 5 | blah | blah |
| 6 | blah | blah |
| 7 | blah | blah |
| 8 | blah | blah |
| 9 | blah | blah |
| 10 | blah | blah |
| 11 | blah | blah |
+---------+--------+--------+
 

Mucman

Diamond Member
Oct 10, 1999
7,246
1
0
What are you grabbing the data from? If the query is part of a script it would be simply a matter of adding a counter variable to increment
for every row that is returned...