当前位置:  开发笔记 > 编程语言 > 正文

SQL:4个条件与OR结合使用

如何解决《SQL:4个条件与OR结合使用》经验,为你挑选了0个好方法。

问题是,

确定船舶表中满足以下列表中至少四个标准组合的所有船舶的名称:numGuns = 8 bore = 15 displacement = 32000 type = bb started = 1915 class = Kongo country = USA.

我找到了这个练习的答案.

答案是,

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

我的问题是,

有没有其他简单的方法检查条件.

推荐阅读
手机用户2502851955
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有