Thursday, August 27, 2009

MySql query to create a sequence of integers

The following sql query would generate a sequence of integers. This can be combined with other sql queries as a subquery.

select @rownum:=@rownum+1 as seq from (select @rownum:=-1) seed, SomTable t1,SomeTable limit


SomeTable can be any table that has enough rows so that the cross product is greater than the upper bound.

No comments: