这样的条件怎么加,高手帮忙

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

有一个表a,里面有一列b  
  现在就是要查表a中的所有数据,条件没有,一般写成select   *   from   a   就可以了,但现在同样是要查a中的所有数据,要求加一条件,要加在列b上,只要b中有数据就行,也就是要写成select   *   from   a   where   b   =   所有数据,就是要强硬在b上加条件,但这个条件要满足能查出表a中的所有数据

· 网友精彩回答:

发表者:wangdehao

select   *   from   a   where   b   is   not   null    
   
  --楼主是这个意思吗?

发表者:zlp321002

--好象是,:d

发表者:paoluo

应该是这个意思吧。  
   
  select   *   from   a   where   b   is   not   null   and   b<>

发表者:zlp321002

select   *   from   a   where   b   like   %你要的字符串%

发表者:wangdehao

select   *   from   a   where   1=1  
   
  ---难道是这个意思?  
  ---还可以加   select   *   from   a   where   1=1   and   b   is   not   null   and   b<>  
  ---楼主最好说清楚你想实现什么,遇到了什么困难

发表者:jixiaojie

 
  string   a;  
  a   =   "b";  
  a="select   *   from   test   where   b="+a;  
   
  再把a   传入sql,不知道这样行不行  
   
 

发表者:vivianfdlpw

string   sql="select   *   from   test   where   b=b"

发表者:wangdehao

--这部分可以在程序中实现啊,是这个意思吗?  
  string   sql="select   *   from   test   where   1=1"  
  string   a  
  if   a<>""  
  sql=sql+"   and   b="+a  
   
   
 

发表者:jiushaoye

select   *   from   t   where   isnull(b,)   =   isnull(b,)

发表者:tntzbzc

我是这样理解楼主的意思的,只要b列中的任何一行的数据满足某种条件,那所有数据就都能被查询  
   
  select   *   from   table   where   exists(select   *   from   table   where   b=?????)  
  --?????是要加的条件字段  
  反之,如果只要b列某行不满足某种条件:  
  select   *   from   table   where   not   exists(select   *   from   table   where   b=?????)  
  --?????是要加的条件字段  
 

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved