尝试创建一个获取与用户相关的最新记录的查询。这是我的尝试
"SELECT *
FROM (
SELECT *
FROM mytable
ORDER BY id
DESC LIMIT 1)
WHERE userid = $userID";
答案 0 :(得分:2)
你也可以:
Select * from table
Where id =
(Select Max(Id) from table
where userid = $userID)
答案 1 :(得分:1)
只需跳过子查询:
SELECT *
FROM mytable
WHERE userid = $userID
ORDER BY id DESC
LIMIT 1
答案 2 :(得分:0)
使用热门(1)
Select TOP(1) * FROM table ORDER BY id DESC
答案 3 :(得分:0)
尝试:
SELECT *
FROM mytable
WHERE userid = $userID
ORDER BY id DESC
LIMIT 1