How do i cross join , Inner join and Group tables

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 order_table) as yw1
(SELECT * FROM products) as yw2 ON yw1.product_id =
(SELECT * FROM category) as yw5 ON yw2.product_category =
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 |

First, JOIN, INNER JOIN and CROSS JOIN are exactly the same thing. What do you want to get out?

This might work, but, we would need to know what you want out of it. Your query SELECTs data and you join the data, but, I think you need to join the tables. Also not sure you can GROUP-BY one category, you might need to change that section to use a WHERE instead. Again, it depends on what you want out of the query. If you want to total ALL orders that contain “MEAT”, then you group them and use a WHERE to select only the “MEAT” values. If you want a list of all “MEAT” orders, you drop the group and just use the WHERE… Hope this helps!

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service