gpt4 book ai didi

mysql - SQL 查询 - 查找不存在子帖子的父帖子

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

我正在使用以下查询:

SELECT 
count(tblReplies.repDate) as comReplies,
tblReplies.repDate
FROM tblReplies, tblQuestions, tblUsers
WHERE
tblQuestions.queID = tblReplies.repQuestionID
AND tblQuestions.queCompanyID = tblUsers.uCompanyID
AND tblUsers.uID = tblReplies.repUserID
AND tblUsers.uCompanyID = $comID
AND tblQuestions.queID = $queID
GROUP BY tblReplies.repID
ORDER BY tblReplies.repDate ASC

现在,我正在尝试修改查询以查找 tblQuestions (queID) 中没有回复的帖子(数据库 tblReplies 中没有子项的问题)。任何人都有想法,我完全迷路了,希望那里有忍者:)

谢谢,

最佳答案

select q.*
from tblQuestions q
left outer join tblReplies r on q.queID = r.repQuestionID
where r.repQuestionID is null

关于mysql - SQL 查询 - 查找不存在子帖子的父帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14532618/

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