I need to add a column of incremental numbers (1,2,3,4,5,6...)in my query. I cant modify the table im running the select on, but i want to do something like "SELECT RAND(), blah, blah FROM blah" Having incremental numbers instead of random numbers.
thanks
its on a mySQL server btw
SELECT myStuff FROM myTable WHERE myID IN (1,2,5,7,9)
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.
Field1
Field2
Inc Num
+---------+--------+--------+ | 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 | +---------+--------+--------+
SELECT Field1, Field2 FROM yourTable WHERE IncNum IN (1,3,5,7,9,11)
will return every other row.
SELECT Field1, Field2 FROM yourTable WHERE IncNum > 4 and IncNum < 11
will return rows 5 thru 10.
What is it you want to get out of the database?