我有两张桌子:
仓库
装运
我希望列出orderID
从公司在纽约的所有仓库发货的订单。
我试过的查询
select orderID
from shipment
join shipment on warehouse.warehouseID = shipment.warehouseID
where warehouse.Wcity = "new york";
答案 0 :(得分:1)
你正在做自我join
而不是加入另一张桌子。请尝试以下方法:
select s.`OrderID`
from `Shipment` s
join `Warehouse` w on w.`WarehouseID` = s.`WarehouseID`
where w.`WCity` = 'new york';