不匹配时仍为 return JOIN 结果

Still return JOIN result when no match

我的一个查询中有一个 join,但是当 join returns 什么都没有时,主查询本身 returns 什么也没有,并且不确定如何仍然有当 join 失败时查询 运行。

SELECT 
"Wishlist".*, 
COUNT("WishlistItem".*) AS "wishlistItemCount" 
FROM "Wishlist" 
INNER JOIN "WishlistItem" 
ON ("WishlistItem"."wishlistId" = "Wishlist"."wishlistId") 
WHERE ((("Wishlist"."wishlistId" = ) OR ("Wishlist"."userId" = )) 
AND 1=1) GROUP BY "Wishlist"."wishlistId" 
ORDER BY "Wishlist"."dateCreated" 
DESC

所以我想要 Wishlist 的内容,即使 WishlistItem 计数 returns 不匹配。

我在 COUNT(*) 上尝试了 coalesce,但没有帮助

将其从内部联接更改为左外部联接。

SELECT 
    "Wishlist".*, 
    COUNT("WishlistItem".*) AS "wishlistItemCount" 
FROM "Wishlist" 
    LEFT OUTER JOIN "WishlistItem" 
    ON ("WishlistItem"."wishlistId" = "Wishlist"."wishlistId") 
WHERE ((("Wishlist"."wishlistId" = ) OR ("Wishlist"."userId" = )) 
    AND 1=1) GROUP BY "Wishlist"."wishlistId" 
ORDER BY "Wishlist"."dateCreated" 
DESC