我怎麼能得到這個SQL語句更小,就像只在某處使用WHERE來獲得更快的結果?謝謝!SQL如何更快地從語句中獲得結果?
SELECT p.model, pc.price FROM Product AS p
JOIN PC AS pc
ON pc.model = p.model
WHERE p.maker='B'
UNION
SELECT p.model, lp.price FROM Product AS p
JOIN Laptop AS lp
ON p.model = lp.model
WHERE p.maker='B'
UNION
SELECT p.model, pr.price FROM Product AS p
JOIN Printer AS pr
ON p.model = pr.model
WHERE p.maker='B'
編輯:我想它要快。
非常容易閱讀,因爲它是。爲什麼改變它? –
我教了也許有一個更好/更快的方式來獲得結果。 –
除了標準化爲一個產品表,並有一個指定類型的標識符... –