Sometimes the first step to solving your problem is to know what he called. After that, it's just a search question. What you are trying to create is called a pivot table or crosstab report . Here is a link explaining how to create pivot tables in MySQL . And here is a more detailed tutorial .
UPDATE:
Now that you have updated the question, I have a clearer idea of ββwhat you are trying to accomplish. I will give you an alternative solution that looks like, but not quite what you want, based on the MySQL GROUP_CONCAT function.
select t1.FirstName, t1.LastName, group_concat(concat(t2.FirstName, ' ', t2.LastName)) from member_information as t1 left outer join member_dependent_information as t2 on t2.MemberID=t1.MemberID group by t1.MemberID;
I checked this query as follows. First install:
create table member_information ( MemberID int unsigned auto_increment primary key, FirstName varchar(32) not null, LastName varchar(32) not null ) engine=innodb; create table member_dependent_information ( MemberID int unsigned not null, FirstName varchar(32) not null, LastName varchar(32) not null, Type int unsigned not null, foreign key (MemberID) references member_information(MemberID) ) engine=innodb; insert into member_information (MemberID, FirstName, LastName) values (1, 'John', 'Harris'), (2, 'Sarah', 'Thompson'), (3, 'Zack', 'Lewis'); insert into member_dependent_information (MemberID, FirstName, LastName, `Type`) values (1, 'Amy', 'Harris', 1), (2, 'Bryan', 'Thompson', 1), (2, 'Dewey', 'Thompson', 2), (2, 'Tom', 'Thompson', 2), (3, 'Harry', 'Lewis', 2), (3, 'Minka', 'Lewis', 1);
And now the query and results:
mysql> select t1.FirstName, t1.LastName, group_concat(concat(t2.FirstName, ' ', t2.LastName))from member_information as t1 -> left outer join member_dependent_information as t2 on t2.MemberID=t1.MemberID -> group by t1.MemberID; +-----------+----------+------------------------------------------------------+ | FirstName | LastName | group_concat(concat(t2.FirstName, ' ', t2.LastName)) | +-----------+----------+------------------------------------------------------+ | John | Harris | Amy Harris | | Sarah | Thompson | Bryan Thompson,Dewey Thompson,Tom Thompson | | Zack | Lewis | Harry Lewis,Minka Lewis | +-----------+----------+------------------------------------------------------+ 3 rows in set (0.00 sec)