I know this is not a good practice of creating a table, so please let those thing aside first.
I have a table, let say table A and table B
Table A :
| ID | fk_tableB_ID | title
-------------------------
| 10 | 1,2 | title 1
| 11 | 3 | title 2
Table B :
| ID | category
---------------
| 1 | cat1
| 2 | cat2
| 3 | cat3
I tried this query:
SELECT
a.ID,
a.title,
(
SELECT
group_concat(b.category)
FROM
tableB B
WHERE
B.ID IN (a.fk_tableB_ID)
) as category
FROM
tableA a
It return :
| ID | category | title
-----------------------
| 10 | cat1 | title1
| 11 | cat3 | title2
But that's not what i want. What i want is
| ID | category | title
-----------------------
| 10 | cat1,cat2 | title1
| 11 | cat3 | title2
Please help, what is the correct mysql query code so i can get that table above. Thx in advance