Car: Contract: Customer:
Carplate (PRKEY) Contractid(PRKEY) CustomerID(PRIK)
PRICE Miles Customername
Leased(0Free- 1Leased) Carplate(FKEY) Zipcode
ContractID FKEY)
Carplate(FKEY)
我想所有的租賃汽車(= 1),他們目前的英里,客戶名稱和組由(錯誤階通過)客戶的郵政編碼。
語法
SELECT *
FROM table1 INNER JOIN table2 ON
table1.primaryKey=table2.FKEY INNER JOIN
table3 ON table2.primaryKey=table3.FKEY
問題:我不懂propper使用INNER JOIN的這裏和where子句。
Select Car.Leased, Contract.Miles, Customer.Customername, Customer.Zipcode
From Car
INNER JOIN Contract on Car.Carplate = Contract.Carplate
INNER JOIN Customer on Contract.Carplate = Customer.Carplate
where Car.Leased = 1
order by Customer.Zipcode ASC
試圖通過語法創建代碼。這是正確的?
看起來很好。你有預期的結果嗎? – jarlh
'JOINs'最終創建了涉及表的行的幾個組合,具體取決於它的類型 - 「INNER,OUTER,LEFT,RIGHT,」等。where子句過濾掉相關的。 –
Iam通過紙張學習。 –