各位大侠:select * from a; 这样列出所有的数据如果我想在where 中增加条件,比如在a表中有custid字段,我在where中 输入什么值会显示所有的数据,custid=?主要想通过这个来灵活的取值,输入某个值,显示不同的结果

解决方案 »

  1.   

    显示全部不必要加where条件
    灵活的取值,就用变量来替换,可以写一个带输入参数的过程
      

  2.   

    对,我就想知道在where中那个代表所有的数据
      

  3.   

    where 1=1 or custid = ?
      

  4.   

    这不可能的,只能写两个SQL语句
      

  5.   

    select * from a 
    where a.custid like '%%'
    这样就可以显示全部数据了
      

  6.   

    select * from tb where 1=1

    select * from tb where nvl(custid,'') like '%%'
      

  7.   

    这些动态取数,用procedure比较好,你想加多少个条件都得,如下:v_where:='1=1';if @a is not null then
       v_where:=v_where || ' and tb.a='||@a;end ifif @b is not null then
       v_where:=v_where || ' and tb.b='||@b;
    end if
    ...
    ..........select * from tb where ||v_where
      

  8.   

    这些动态取数,用procedure比较好,你想加多少个条件都得,如下:v_where:='1=1';if @a is not null then
       v_where:=v_where || ' and tb.a='||@a;end ifif @b is not null then
       v_where:=v_where || ' and tb.b='||@b;
    end if
    ...
    ..........select * from tb where ||v_where