I will try to explain the problem I’m facing.
I have two tables: Team and Team_contacts
In the first table there is info like:
member_name, member_picture, phone and email
In the team_contacts table there are only countries and cities the member is responsible for.
So the first table looks like this:
member_id: 1
member_name: moonwalker
member_picture: mw.jpg
member_phone: 06xxxxxxxx
member_email: mw@moonwalker.com
The second table looks like this:
member_id: 1
country: USA
city: California
member_id: 1
country: USA
city: Miami
member_id: 1
country: NL
city: Amsterdam
What I need is a query that shows the following:
mw.jpg
Moonwalker
Phone: 06xxxxxxxx
Email: mw@moonwalker.com
Active in countries: USA, NL
Active in cities: California, Miami, Amsterdam
I tried different join methods, but nothing seems to work. Is there a way to do this with a single query or do I need to use two different queries? And how?
Thanks a lot for the help.
As you are using MySQL you can do:
Be aware that the length of the list is limited by
group_concat_max_lenwhich is by default 1024, unless you change it using for example: