普通网友 2016-02-16 06:15
浏览 30

检查具有特定ID的4个不同表中的列值以及失败的返回通过

Tabel_1:

Id    test_id  testname    passfail
1      1001       test1      pass
2      1001       test2      fail
3      1002       test11     pass
4      1002       test12     pass
5      1003       test21     fail
6      1003       test22     fail

Tabel_2:

Id    test_id  testname    passfail
1      1001       test1      pass
2      1001       test2      pass
3      1001       test3      pass
4      1002       test11     pass
6      1002       test13     fail
7      1002       test13     fail

Tabel_3:

Id    test_id  testname    passfail
4      1002       test11     pass
5      1002       test12     pass
6      1003       test31     fail
7      1003       test32     fail

Tabel_4:

Id    test_id  testname    passfail
1      1001       test1      pass
2      1001       test2      pass
3      1001       test3      pass
4      1003       test11     pass
5      1003       test12     pass

I want to check passfail column in all table(Tabel_1, Tabel_2, Tabel_3, Tabel_4) with specific test_id like 1001 or any test_id. if any of row has fail for passfail column belong to id like 1001 then query will be returned only once fail or no fail found in passfail column belong that specific test_id then query will be returned only once pass from passfail colomn.

  • 写回答

3条回答 默认 最新

  • duanbi8089 2016-02-16 06:34
    关注

    You can combine the result of each SELECT by using UNION DISTINCT:

    SELECT test_id FROM Table_1 WHERE passfail = 'fail'
    UNION DISTINCT
    SELECT test_id FROM Table_2 WHERE passfail = 'fail'
    UNION DISTINCT
    SELECT test_id FROM Table_3 WHERE passfail = 'fail'
    UNION DISTINCT
    SELECT test_id FROM Table_4 WHERE passfail = 'fail'
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题