Mysql: Confuses the question of joining two tables

I have two tables:

Warehouse

  • Warehouseid
  • WCity

Shipment

  • OrderID
  • Warehouseid
  • Shipdate

I am looking for a list orderIDfor orders that were shipped from all of the warehouses the company has in New York.

The request I tried

select orderID
from shipment
join shipment on warehouse.warehouseID = shipment.warehouseID
where warehouse.Wcity = "new york";
+4
source share
1 answer

You are doing self joininstead of joining another table. Try the following:

select s.`OrderID`
from `Shipment` s
join `Warehouse` w on w.`WarehouseID` = s.`WarehouseID`
where w.`WCity` = 'new york';
+1
source

All Articles