archer
archer

Reputation: 89

Mysql: Confused about query joining two tables

I have two tables:

Warehouse

Shipment

I am looking to list the orderID for orders that were shipped from all warehouses that the company has in New York.

The query I tried

select orderID
from shipment
join shipment on warehouse.warehouseID = shipment.warehouseID
where warehouse.Wcity = "new york";

Upvotes: 4

Views: 74

Answers (1)

potashin
potashin

Reputation: 44581

You are doing a self join instead 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';

Upvotes: 1

Related Questions