Use a subquery in the FROM clause to only retrieve invoices from chamber 'H' and the invoice amount of larger than 10000 and join the result with the voyages table using the number column. Project to only retrieve the boatname and the invoice amount of the join result. Order by invoice amount.
所以,我做了這個:
SELECT chamber =
(
SELECT chamber
FROM invoices
INNER JOIN voyages ON chambers.chamber ='H'
AND chambers.invoice > 10000
AND invoice.number=voyages.number
),
boatname,
invoice
FROM chambers,
voyages,
invoices
WHERE chambers.chamber = invoices.chamber,
invoices.number = voyages.number
這是室表:
# chamber name
1 A New York
這是發票表:
# number invoice chamber
1 8300 9189 A
然而,它不斷給我這個錯誤:Query failed: near ",": syntax error
你不能用','來分隔WHERE子句語句。你需要使用'AND'或'OR'。 – Siyual
您還應該停止使用隱式的'JOIN'語法。你應該在FROM子句中永遠不要有''''。這種古老的'JOIN'風格已被棄用*超過25年*。 – Siyual
@CSharper他們不會。但你應該問OP,而不是我。 – Siyual