how do i print a record coming from joinig query as follows in mysql tbl_A
 ---------------
| a_id | a_name |
|------|--------|
| 1    | john   |
| 2    | paul   |
| 3    | joy    |
 ---------------


tbl_B
 ---------------
| a_id | b_name |
|------|--------|
| 1    | x      |
| 1    | y      |
| 1    | z      |
 ---------------


RESULT

    tbl_C
 -----------------
| a_name | b_name |
|--------|--------|
| john   | x,y,z  |
 -----------------
Use group_concat to merge multiple field rows into one field

create table A(a_id,a_name);
create table B(a_id,b_name varchar(5));
insert into A values(1,'john'),(2,'paul'),(3,'joy');
insert into B values(1,'x'),(1,'y'),(1,'z');

set group_concat_max_len = 4096; -- default: 1024

-- the query
select A.a_name, group_concat(B.b_name separator ',') 
from A, B 
where A.a_id = B.a_id 
group by A.a_name;

-- result
+--------+--------------------------------------+
| a_name | group_concat(B.b_name separator ',') |
+--------+--------------------------------------+
| john   | x,y,z                                |
+--------+--------------------------------------+
1 row in set (0.00 sec)