user3198486 user3198486 - 1 month ago 5
MySQL Question

How to create this query in MYSQL? What Join is it?

i cannot create this kind of join

I have two tables on my MySQL database one is for the identity record and the another one is for , i know how to create joins like inner, left, right joins BUT i do not know how to create a join that will merge them

enter image description here

Answer

It's not the join that's different, you need to use group by clause and group_concat() function to produce the expected results in the record field of the output. Whether it is a left or inner join between the 2 tables, that's for you to decide. Based on the sample data an inner join will work just fine:

SELECT a.id_tag, a.Name, group_concat(b.Record) as record
FROM table1 a INNER JOIN table2 b ON a.id_tag = b.id_tag
group by a.id_tag, a.Name
Comments