我在限制Jokes
表格中的行数方面存在问题。
这是我的查询工作,获取所有行:
SELECT Jokes.ID, Categories.CategoryName, Jokes.CategoryID, Jokes.JokeText
FROM Jokes
LEFT JOIN Categories
ON Jokes.CategoryID = Categories.ID
ORDER BY Jokes.ID DESC
它会是什么样的?
SELECT Jokes.ID, Categories.CategoryName, Jokes.CategoryID, Jokes.JokeText
FROM (
SELECT * FROM Jokes ORDER BY ID DESC Limit 0,40)
AS a
LEFT JOIN Categories
AS b
ON a.CategoryID = b.ID
答案 0 :(得分:3)
为什么不使用
SELECT Jokes.ID, Categories.CategoryName, Jokes.CategoryID, Jokes.JokeText
FROM Jokes
LEFT JOIN Categories
ON Jokes.CategoryID = Categories.ID
ORDER BY Jokes.ID DESC
Limit 0,40