I want to get the values of a row using joining.
I have a category table like this:
id | category_name
1 | books
2 | car
3 | Furniture
and another product table like this:
id | product_name | category_id
1 | The little Bee | 2
2 | New Year | 1,3
I want to call the product table and output the category_name instead of the category_id. But not only that. I want the category_id that has more than one category e.g New Year has category_id 1 and 3, it should show Book, Furniture as the category_name.
This is my code:
SELECT p.*, c.*
FROM products p, category c
WHERE p.category_id = c.id
But I am only getting one category for categories with more than one. How can I get the complete categories? I guess it deals with joining but I'm not sure.