sql - Still return JOIN result when no match -


i have join in 1 of queries when join returns nothing, main query returns nothing , not sure how still have query run when join fails.

select  "wishlist".*,  count("wishlistitem".*) "wishlistitemcount"  "wishlist"  inner join "wishlistitem"  on ("wishlistitem"."wishlistid" = "wishlist"."wishlistid")  ((("wishlist"."wishlistid" = $1) or ("wishlist"."userid" = $2))  , 1=1) group "wishlist"."wishlistid"  order "wishlist"."datecreated"  desc 

so i'm wanting contents of wishlist when wishlistitem count returns no match.

i attempted coalesce on count(*) didn't help

change inner join left outer join.

select      "wishlist".*,      count("wishlistitem".*) "wishlistitemcount"  "wishlist"      left outer join "wishlistitem"      on ("wishlistitem"."wishlistid" = "wishlist"."wishlistid")  ((("wishlist"."wishlistid" = $1) or ("wishlist"."userid" = $2))      , 1=1) group "wishlist"."wishlistid"  order "wishlist"."datecreated"  desc 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -