我有两张桌子:
仓库
仓库ID
沃特
装运
订单编号
仓库ID
发货日期
我想列出从公司在纽约的所有仓库发货的订单的orderID
我试过的问题

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

最佳答案

你做的是自我join而不是加入另一个表。请尝试以下操作:

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

08-28 15:33