-3

My first table name is user, this table contain products like by user

user

id username products
1  abc       2,3,4
2  cde       1,2

another table products contain related products list

id products
1   pro1
2   pro2
3   pro3
4   pro4

Now i want show user contained products, but not show products id. output like,

abc pro2,pro3,pro4
Akina
  • 39,301
  • 5
  • 14
  • 25
gvn
  • 3
  • 5
  • Please don't store CSV in your SQL tables. – Tim Biegeleisen Dec 04 '20 at 04:17
  • You should not store comma seperated values in one column Please read [this](https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad/3653574#3653574) – catcon Dec 04 '20 at 04:36

1 Answers1

0

SELECT u.username, GROUP_CONCAT(p.products ORDER BY p.id) products_list FROM users u INNER JOIN products p ON FIND_IN_SET(p.id, u.products) > 0 GROUP BY u.id;

SQLFiddle Demo