0

我有以下结构的三个表:

Car-Owners                            CarRecords                           Cars

ownerName  ownerID                 ownerID   carID                     carID   carName

我想列出拥有特定汽车(比如本田思域)的所有车主,并显示车名和车主姓名。我对 JOIN 语句不太了解,而且我似乎无法将如何使用它的各个点联系起来。

4

2 回答 2

1

所以你可能想做的是这样的:

select Car-Owners ownerName, Cars carName 
from Car-Owners, CarRecords, Cars 
 where Car-Owners.ownerId = CarRecords.ownerId 
 and CarRecords.carID = Cars.carId;

从技术上讲,这是一个内部连接,只是它不明确。

于 2013-09-20T19:35:44.230 回答
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'
于 2013-09-20T19:38:18.137 回答