這是否需要聯盟?在聯合和布爾條件之間進行選擇
SELECT vend_id, prod_id, prod_price
FROM products
WHERE prod_price <= 5
UNION
SELECT vend_id, prod_id, prod_price
FROM products
WHERE vend_id IN (1001,1002);
或者這樣做,如果你這樣做?
SELECT vend_id, prod_id, prod_price
FROM products
WHERE prod_price <= 5
OR vend_id IN (1001,1002);
你不會得到兩行,因爲'union'過濾掉重複(而不是'union all')。 – Andomar 2010-06-09 09:05:22