Wednesday, March 11, 2009

Mysql: Oracle users looking for Rownum in mysql !!

Sadly, MySQL doesn't have (yet) the ROWNUM function. But a simple playing around with variables will give you the desired result.

Here is an example: (Src: dzone)
mysql code
SELECT @rownum := @rownum + 1 as rownum, t.* FROM some_table t, (SELECT @rownum := 0) r


2 comments:

  1. thanks this works great

    ReplyDelete
  2. Wynn's new $3.7 billion Las Vegas casino opened this fall
    Wynn 성남 출장안마 Resorts announced 영주 출장안마 today it will 동해 출장샵 unveil $3.7 여수 출장샵 billion casino project, Wynn Plaza, in the resort's 속초 출장마사지 main lobby,

    ReplyDelete