gpt4 book ai didi

mysql - 如果未找到任何行,则查询失败

转载 作者:行者123 更新时间:2023-11-29 01:44:30 25 4
gpt4 key购买 nike

如果没有匹配的问题或用户答案,我有以下查询,它为每个字段返回 NULL。请告诉我如何防止这种情况发生?

谢谢!

SELECT u.id, u.first_name, u.last_name, u.email, u.username, COUNT( DISTINCT q.id ) AS  `q_count` , COUNT( DISTINCT a.id ) AS  `a_count` 
FROM `users` AS u
INNER JOIN `questions` AS q ON u.id = q.uid
INNER JOIN `answers` AS a ON u.id = a.uid
WHERE u.username = 'max'
LIMIT 0 , 30

最佳答案

使用left join代替inner join

关于mysql - 如果未找到任何行,则查询失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10542747/

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