How can I get a query that answers the following
I have the following table entries in a mysql database. I have a lot but this is just an example.
ID EMAIL CUSTOM_1
1 firstname.lastname@example.org null
2 email@example.com null
3 firstname.lastname@example.org email@example.com
4 firstname.lastname@example.org email@example.com
5 firstname.lastname@example.org null
LABEL (there are lots of these):
How do I get a query to show:
- display user's ID, email address and ALL the labels they are in of any kind (comma separated)
- - that I have only one row per user.
- only show their row label for certain LABELS. e.g. A
- do NOT show a row for users if they are in both the previous list and also a specific list of labels e.g. SAD/GLAD
- also show users that are not in a label at all
- display whatever email is relevant for "company.com" only not "company2.com"
- if there is no email address at all then show "unknown"
- for users with no label then show string "needs THERE-X label"