Question:
Define the names of all ships in the Ships table that match the combination of at least four criteria from the following list: numGuns = 8 bore = 15 displacement = 32000 type = bb launched = 1915 class = Kongo country = USA.
I found the answer for this exercise.
Answer:
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
My question is:
Is there any other easy way to check the conditions.
user5443453
source share