gpt4 book ai didi

php - 使用 LIMIT 选择左连接

转载 作者:太空宇宙 更新时间:2023-11-03 12:14:00 24 4
gpt4 key购买 nike

我在限制 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

最佳答案

为什么不使用

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

关于php - 使用 LIMIT 选择左连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23022930/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com