我有一张这样的表:
╔════════════════════════════════════════════════════╗
║ id project_id resource role start_date ║
╠════════════════════════════════════════════════════╣
║ 1 1 Tom Engg 2013-09-10 ║
║ 2 1 Sam Clerk 2013-08-23 ║
╚════════════════════════════════════════════════════╝
有没有一种方法可以找到行号id,比如使用sql查询id = 2。 请提出解决方案。提前谢谢。
答案 0 :(得分:1)
试试这个::
SELECT @rownum:=@rownum + 1 as row_number,
t.*
FROM (
< your original query goes here >
) t,
(SELECT @rownum := 0) r
答案 1 :(得分:0)
你可以试试这个
select rownum id from your_table where your_condition