我有以下结构中的三个表:
Car-Owners CarRecords Cars
ownerName ownerID ownerID carID carID carName
我想列出拥有特定车辆的所有车主(比如本田思域),并显示车名和车主姓名。我对JOIN声明不太满意,似乎无法将如何使用它连接点。
答案 0 :(得分:1)
所以你可能想要做的是这样的事情:
select Car-Owners ownerName, Cars carName
from Car-Owners, CarRecords, Cars
where Car-Owners.ownerId = CarRecords.ownerId
and CarRecords.carID = Cars.carId;
从技术上讲,这是一个内部联接,但它并不明确。
答案 1 :(得分:0)
SELECT CO.ownerName, C.carName
FROM Car-Owners AS CO
INNER JOIN CarRecords CR ON CO.ownderID = CR.ownerID
INNER JOIN Cars C ON C.carID = CR.carID
WHERE carName = 'Delorean'