SQL - 如何使其成为 JOIN ON 语句 [已关闭]

问题描述 投票:0回答:1
SELECT LastName, FirstName, Phone
    FROM CUSTOMER, SALE, SALE_ITEM, ITEM
    WHERE CUSTOMER.CustomerID = SALE.CustomerID
    AND SALE.SaleID = SALE_ITEM.SaleID
    AND SALE_ITEM.ItemID = ITEM.ItemID
    AND ItemDescription LIKE '%Desk Lamp%';

不确定在哪里添加连接

sql mysql mysqli mysql-connector
1个回答
0
投票
SELECT LastName, FirstName, Phone
FROM CUSTOMER AS C
JOIN SALE AS S ON C.CUSTOMER_ID=S.CUSTOMERID
JOIN SALE_ITEM AS S_ITEM ON S.SALEID=S_ITEM.SALEID
JOIN ITEM AS I ON S_ITEM.ItemID =I.ITEMID
WHERE I.ItemDescription LIKE '%Desk Lamp%';

请尝试这样的事情

© www.soinside.com 2019 - 2024. All rights reserved.