Suppose I have the following two tables in my MySQL database:
Table 1:: EMP: EmpID, EmpName
eg. (1, 'John'), (2,'Alex'),(3,'Tom')
Table 2:: Team: TeamID, ManagerID, MemberID
eg. record1: (Team1, 1, 2), record2: (Team1, 1, 3)
so there is a team with id team1, John is the manager and Alex and Tom are its members.
I want to display the records of the Team table on the screen in the following manner
| Team | Manager | Members |
| team1 | John | Alex, Tom |
What should be SQL query which will join the above two tables and return me the names of the members when based on the memberIDs.
Also the result will be displayed as 1 row containing all the team members separated by a comma.
If there is a better way of designing these two tables then please suggest that also. It will be much appreciated.
Thanks.