SELECT field1, field2
FROM table 1
How can I add an auto-increment temporary id field to query results?
SELECT field1, field2
FROM table 1
How can I add an auto-increment temporary id field to query results?
Try this in MySQL:
SELECT @s:=@s+1 ,field1, field2
FROM table1,
(SELECT @s:= 0) AS s
In MSSQL it would be
SELECT row_number() OVER (ORDER BY field1, field2) n,
field1, field2
FROM table1