grocery_visits and fishmarket_visits are NULL for users without any related entries in the respective tables. If you need 0 instead (or any arbitrary number), use COALESCE in the outer SELECT:SELECT u.id , u.account_balance , COALESCE(g.grocery_visits , 0) AS grocery_visits , COALESCE(f.fishmarket_visits, 0) AS fishmarket_visitsFROM ... 这篇关于两个 SQL LEFT JOINS 产生不正确的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-13 05:01