質問は、SQL:4と組み合わせ条件OR
以下のリストからの少なくとも4つの基準の組み合わせを満たす船テーブル内のすべての船舶の名前を決定する:= 8ボアnumGuns = 15変位= 32000タイプ= bb打ち上げ= 1915クラス=コンゴ国=米国。
私はこの練習問題の答えを見つけました。
答えは、
SELECT s.name from ship s,classes c
WHERE s.class=c.class AND
((numGuns = 8 AND bore = 15 AND displacement = 32000 AND type = 'bb')
OR (numGuns = 8 AND bore = 15 AND displacement = 32000 AND launched = 1915)
OR (numGuns = 8 AND bore = 15 AND displacement = 32000 AND c.class = 'Kongo')
OR (numGuns = 8 AND bore = 15 AND displacement = 32000 AND country = 'USA')
OR (numGuns = 8 AND bore = 15 AND type = 'bb' AND launched = 1915)
OR (numGuns = 8 AND bore = 15 AND type = 'bb' AND c.class = 'kongo')
OR (numGuns = 8 AND bore = 15 AND type = 'bb' AND country = 'USA')
OR (numGuns = 8 AND bore = 15 AND launched = 1915 AND c.class = 'Kongo')
OR (numGuns = 8 AND bore = 15 AND launched = 1915 AND country = 'USA')
OR (numGuns = 8 AND bore = 15 AND c.class = 'Kongo' AND country = 'USA')
OR (numGuns = 8 AND displacement = 32000 AND type = 'bb' AND launched = 1915)
OR (numGuns = 8 AND displacement = 32000 AND type = 'bb' AND c.class = 'kongo')
OR (numGuns = 8 AND displacement = 32000 AND type = 'bb' AND country = 'USA')
OR (numGuns = 8 AND displacement = 32000 AND launched = 1915 AND c.class = 'Kongo')
OR (numGuns = 8 AND displacement = 32000 AND launched = 1915 AND country = 'USA') O
私の質問があり、
は条件をチェックし、他の簡単な方法があります。
意味のタイトルを教えてください。 –
はい、それらを単純化するために 'WHERE'節のまわりを移動してください。 – Ruslan
@Ruslan意味は? –