MySQL Forums
Forum List  »  MySQL Query Browser

group_concat Query w/ Generated Nulls
Posted by: n/a n/a
Date: July 06, 2018 04:01PM


I am trying to generate a query that produces an array in the form of a delimited group_concat with the caveat that it is populated with NULL or empty sets when there isn't a matching combination in the lookup table.

I would add that I am not the database administrator so I am limited in terms of schema/table setups and the integrity of the data I am querying. I have provided a visual example below of what I am looking for.

I am a bit rusty on my MySQL, but I have been explored quite a few places on the web without finding quite what I am looking for, and it is difficult to express my need in a very searchable phrase. Any help is certainly appreciated:

Table 1:

PID | Category
1 | Chairs
2 | Hats
3 | Appliances

Table 2:

FID | Location
1 | 1
1 | 2
2 | 1
2 | 5
3 | 1
3 | 2
3 | 3
3 | 4
3 | 5

Desired Output From Query:

Category | group_concat(Location)


Category | group_concat(Location)
Hats | 1,,,,5

Options: ReplyQuote

Written By
group_concat Query w/ Generated Nulls
July 06, 2018 04:01PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.