I have 3 tables which are order tables
, product tables
and category_tables
.
I want to get the result of the category
Meat
only from the order_tables
by cross joining it with the product tables
and the category_tables
. But why do i always get the result of the first product with the category i selected. This is the sql i use to select the Meat category
SELECT * FROM (
(SELECT * FROM order_table) as yw1
INNER JOIN
(SELECT * FROM products) as yw2 ON yw1.product_id = yw2.id
CROSS JOIN
(SELECT * FROM category) as yw5 ON yw2.product_category = yw5.id)
GROUP BY category = "Meat"
For example, i selected the Meat category it will show the result of
| id | order_id | product_id | product_name | id | category_name |
| 1 | 10001 | 1 | carrot | 1 | Tubers |
| 4 | 10004 | 4 | Beef | 4 | Meat |