有几张数据表label1,有a、b、c、d、e、f这6个字段,想从其中的b、c、d、e四个字段的值中找出大于1000的,语句该如何写?

解决方案 »

  1.   

    select * from label1
    where a>1000 or b>1000 or c>1000 or d>1000 or e>1000 or f>1000
      

  2.   


    select * from label1
    where b > 1000 or c > 1000 or d > 1000 or e > 1000UNION ALL select * from label2
    where b > 1000 or c > 1000 or d > 1000 or e > 1000UNION ALL
    select * from label2
    where b > 1000 or c > 1000 or d > 1000 or e > 1000
    你可以写成存储过程,传递表的个数和判断条件,在存储过程中使用动态sql进行查询生成
      

  3.   

    SELECT * FROM 
    lable1
    WHERE a>1000 or b>1000 OR c>1000 OR d>1000 OR e>1000 OR f>1000;
      

  4.   

    select * from label1
    where  b>1000 or c>1000 or d>1000 or e>1000 or f>1000
      

  5.   

    +1
    或者用存储过程生成动态SQL。
      

  6.   


    SELECT * FROM 
    lable1
    WHERE b>1000 OR c>1000 OR d>1000 OR e>1000;