Reputation: 23
I'm having a problem sorting my tables in MYSQL.
I have my tables setup like this:
I want to SELECT all orders WHERE printed = FALSE but also sort by the shipping costs and THEN by the SKU_location
How can I join the tables into one query so it sorts by shipping_cost and SKU_location where printed = false?
Upvotes: 2
Views: 3300
Reputation: 53
You can do an implicit JOIN in the following way:
SELECT *
FROM Order_details od
JOIN Product_details pd
ON od.Order_ID = pd.Order_ID
WHERE od.printed = FALSE
ORDER BY od.shipping_cost, pd.SKU_location
The text following each table renames the table for easy reference in the later parts of the query (i.e. the code "Database.Long_Table_Name ltn" renames the table to "ltn")
Upvotes: 4