gpt4 book ai didi

mysql - 从多个类似的只有 id 的请求更改为只有一个

转载 作者:行者123 更新时间:2023-11-29 14:22:03 24 4
gpt4 key购买 nike

我使用不同的 ID 多次执行相同的请求:

SELECT n.id 
FROM news n
JOIN news_tag nt ON r.id=nt.id_news
WHERE nt.id_tag in (Select t.id_tag from news_tag t where t.id_news=2869)
ORDER BY r.id DESC
LIMIT 2

此请求选择与给定新闻具有相同标签的最后 2 条新闻。

我想知道如何执行相同的请求,但仅在一个请求中获取多个 ID 的结果!

最佳答案

这是典型的“每组前 N 个”查询,在您的情况下,“B”为 2

Here's a generic solution我为每组写了 N 条记录。

关于mysql - 从多个类似的只有 id 的请求更改为只有一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11600511/

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