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 email@example.com null
2 firstname.lastname@example.org null
3 email@example.com firstname.lastname@example.org
4 email@example.com firstname.lastname@example.org
5 email@example.com 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"