0

This is related to my previous example question submitted here. I have the following sql query :

SELECT 
listings.*,
region.REGION_ID,
#GROUP_CONCAT(region.REGION_ID) AS GROUP_IDs,
......
......
INNER JOIN schedule ON schedule.SCHEDULE_ID = listings.LISTING_SCHEDULE_ID 
LEFT JOIN listing_region ON listing_region.LIST_REGION_LISTING_ID = 
listings.LISTING_ID 
......
......
WHERE listings.LISTING_ID IN 
(SELECT LISTING_ID FROM listings WHERE ..........

The result is as follows :

Raw data without GROUP_CONCAT

I get multiple RegionIDs for the same ListingID and rest is null (expected) for non-existing records from LEFT join.

Now I need to group region_Ids for the same Listing ID.

So the only change I did was commenting out "region.REGION_ID" and enabled "GROUP_CONCAT(region.REGION_ID) AS GROUP_IDs,".

The result is as follows :

Results with GROUP_CONCAT

I do not understand why null rows are now dropped. I want them...! What should I correct here?

PCG
  • 2,049
  • 5
  • 24
  • 42

1 Answers1

0

The only change I was supposed to do to Add: GROUP BY ListingID to main filter clause.

PCG
  • 2,049
  • 5
  • 24
  • 42