0

我有一张这样的桌子:

╔════════════════════════════════════════════════════╗
║ id    project_id    resource    role    start_date ║
╠════════════════════════════════════════════════════╣
║ 1         1           Tom       Engg    2013-09-10 ║
║ 2         1           Sam       Clerk   2013-08-23 ║
╚════════════════════════════════════════════════════╝

有没有一种方法可以让我找到行号和 id,比如 id=2 使用 sql 查询。请提出解决方案。提前致谢。

4

2 回答 2

1

尝试这个::

SELECT @rownum:=@rownum + 1 as row_number, 
       t.*
FROM ( 
   < your original query goes here >
) t,
(SELECT @rownum := 0) r
于 2013-10-09T06:13:44.383 回答
0

你可以试试这个

select rownum id from your_table where your_condition
于 2013-10-09T06:28:38.803 回答