Is it possible to get row number in MySQL? Say I have a "table"
ID tag name 1 A alpha 4 B beta 5 C gamma 8 D ceta
How can I get in MySQL that, for example, βCβ is the third row in this table? After:
SET @pos=0; SELECT @pos: =@pos +1,tag FROM table ORDER BY tag ASC;
counts lines as it should. But (sorry for the ignorant code)
SET @pos=0; SELECT @pos: =@pos +1,tag FROM table where tag='C' ORDER BY tag ASC;
gives 1 line as a result, with pos as 0, as it probably should be.
Is there a way to make "pos" be "3" as I need? (An order would also be important, regardless of whether it is relevant or not.)
source share