select d.rownum from (SELECT *FROM (SELECT @rownum:=0) c,(SELECT a.*,@rownum:=IFNULL(@rownum,0)+1 rownum FROM tableName a ORDER BY a.colName ) b ) d where d.id='keyWord'