gpt4 book ai didi

Mysql如何限制left join结果

转载 作者:行者123 更新时间:2023-11-29 01:41:35 24 4
gpt4 key购买 nike

我有两个表:歌曲和组

我想限制歌曲匹配组为 3

我试过这个:

SELECT
groups.`IDgroup`,
groups.`name` AS g_name,
songs.`IDsong`,
songs.`name` AS s_name
FROM `groups`
LEFT OUTER JOIN songs ON (groups.`IDgroup` = songs.`IDgroup` LIMIT 3)

最佳答案

limit 放在括号外:

SELECT
groups.`IDgroup`,
groups.`name` AS g_name,
songs.`IDsong`,
songs.`name` AS s_name
FROM `groups`
LEFT OUTER JOIN songs
ON groups.`IDgroup` = songs.`IDgroup`
LIMIT 3

关于Mysql如何限制left join结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20055293/

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