-2

I have the following two tables. I want to join them in a single query.I am able to do it with inner join if the Blog_Category_Id in Blog table is a single value. But when it comes as a multiple value how can i do it?

First Table

Second Table

Below is the result table which i want to show...

Result Table

saptak das
  • 11
  • 1

2 Answers2

1
SELECT b.* ,GROUP_CONCAT(bc.blog_category ORDER BY bc.id) blog_category
FROM blog b 
INNER JOIN blog_category bc ON FIND_IN_SET(bc.id, b.blog_category_id)
GROUP BY b.id
Bedla
  • 4,789
  • 2
  • 13
  • 27
0

You can you FIND_IN_SET in INNER JOIN Check here You may got answer

MySQL Join two tables with comma separated values

SF..MJ
  • 862
  • 8
  • 19