III. Retrieving Data from Multiple Tables - 05 Compound Join Conditions

Hi Mosh,

In the Compound Join Conditions , I did your help as the video to doesn’t show the output. Kindly revert soon.

With regards,
Ritu

SELECT *
FROM order_items oi
JOIN order_item_notes oin
ON oi.order_id = oin.order_id
AND oi.product_id = oin.product_id

Result:
order_id product_id quantity unit_price note_id order_Id product_id note

No record at all!

Mosh, do we need any changes the code?

Output:
3 31 15:37:12 SELECT *
FROM order_items oi
JOIN order_item_notes oin
ON oi.order_id = oin.order_id
AND oi.product_id = oin.product_id
LIMIT 0, 50000 0 row(s) returned 0.000 sec / 0.000 sec

Hi Ritu,
I’m on the same course and topic right now ’ Compound Join Conditions -05 ’ , and wondering if what you shared here is the actual correct Syntax to pull the information up?

1 Like

USE sql_store;

SELECT *
FROM Order_Items OI
INNER JOIN Order_Item_Notes OIN
ON OI.Order_ID = OIN.Order_ID
AND OI.Product_ID = OIN.Product_ID;

/*
No record at all!
*/

SELECT *
FROM Order_Item_Notes;

SELECT *
FROM Order_Items
WHERE Order_ID=1;


UPDATE Order_Item_Notes
SET Product_ID = 4 # It was Product_ID=2
WHERE Order_ID = 1;


SELECT *
FROM Order_Item_Notes;


SELECT *
FROM Order_Items OI
INNER JOIN Order_Item_Notes OIN
ON OI.Order_ID = OIN.Order_ID
AND OI.Product_ID = OIN.Product_ID;

Please check this out.
For Update you haave to go to Edit -->Preferences–>SQL Editor — Scroll down — Safe Update — Unclick that Tab then OK
Close MySQL
Open again
Go to USE sql_store;
Then the Query share above…
Do let me know if any issue