1

How do I translate the following to an equivelant mysql query?

'SELECT ROWID, keyword, value, ref FROM t ORDER BY ROWID'

I found this related link, but I'm not sure how to apply it to what I'm doing here: Equivalent of Oracle’s RowID in MySQL

Community
  • 1
  • 1
Damian Green
  • 633
  • 2
  • 8
  • 13

1 Answers1

1

There is no equivalent to rowid in MySQL. rowid represents the physical location of the record, and that information is not available in MySQL.

The following may be sufficient for what you want:

select (@rn := @rn + 1) as rowid, keyword, value
from t cross join
     (select @rn := 0) const;

Although this query is not guaranteed to return the rows in physical order, in practice it would typically do so. The rowid is just a sequential number in this case.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786