0

假设我想得到logId, userId, updated,updatedById哪里logId大于这个logId找到的最低值userId

我试过了:

SELECT * FROM 
(
SELECT logId, userId, updated, updatedById
FROM users_updatelog
WHERE userid=548
) AS tbl1 
WHERE (tbl1.logId > (SELECT MIN(tbl1.logId) FROM tbl1))
ORDER BY tbl1.updated DESC

但这是不对的。我无法从子查询表 tbl1 中查询(错误消息:无效的对象名称 'tbl1')

任何提示表示赞赏。

4

2 回答 2

4
SELECT logId, userId, updated, updatedById
FROM users_updatelog
WHERE userid = 548
AND logId > (SELECT min(logId) FROM users_updatelog WHERE userid = 548)
ORDER BY updated DESC
于 2013-10-09T07:51:41.790 回答
1
SELECT logId, userId, updated, updatedById
FROM users_updatelog
WHERE userid=548
AND logId > (SELECT MIN(logId) FROM users_updatelog WHERE userid=548)
ORDER BY updated DESC 
于 2013-10-09T07:54:46.347 回答