V
V
vanyaseverin2016-03-30 18:44:43
MySQL
vanyaseverin, 2016-03-30 18:44:43

How to generate an SQL query?

Hello, there are 2 tables
1) product
82c0f3fcc6914782ac2731f3001dcf75.PNG
2) prod_to_cat
8cb29d0943644e19aec597b55aaade54.PNG
How to form a query to get something like this? Given that the product_id is taken from the first table
a799a5c5c6c4449d95e92c42b4f00e18.PNG

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Immortal_pony, 2016-03-30
@vanyaseverin

SELECT 
    `product_id`
    GROUP_CONCAT(`category_id`) AS 'categories'
FROM `prod_to_cat`
GROUP BY product_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question