VB + access 数据库
 
  select * from a where name='%'  通配符 '%'  在语句中代表零个或多个字符  可是当数据表中当某条记录  name 字段内容为空时,  用这个语句却查不出这条记录, 用 '*' 更是不行,一条都查不出来  有没真的 "在语句中代表零个或多个字符" 的通配符啊

解决方案 »

  1.   

    select * from a where name='%' or name=null
      

  2.   

    我是做筛选时贪方便
      
      从 textbox 
      if textbox.text <>""
         str = textbox.text  
      else
         str='%'
      endif
     
     "select * from a where name=" & str ...............条件比较多, 用 where name='%' or name=null 怕会有点乱 , 求经验
      

  3.   

    "select * from a where name like '%" text1.text  "%'"
    text1.text空或不空都可以
      

  4.   

    select * from a where Isnull(name)
      

  5.   


    苗苗的方法不行啊   text1.text 空的当然可以查,但查不出数据库中 name 为空的记录
      

  6.   

    巫山男儿   我不光是只查 name 为空的数据呀,
      

  7.   

    是查询 name 内容为空或不为空的所有记录, name 字段是存在的
      

  8.   

    //是查询 name 内容为空或不为空的所有记录
    那还加过滤干吗?直接
    select * from a
    如果有别的条件,
    select * from a where 别的条件
      

  9.   

    Dim str as string  If textbox.text <>""
         str = "='"& textbox.text & "'"  
      Else
         str="is null"
      Endif
     
     "select * from a where name" & str ...............
      

  10.   

    if textbox.text <>""
         strsql = "select * from a where name='" & textbox.text & "' "  
      else
         strsql = "select * from a where "
      endifstrsql = strsql & " and "其它条件
      

  11.   

    select * from webOrderpower where FPwd like '%' or FPwd is null
      

  12.   

    “%”代表达式0-任意个字符!注意是字符!最少应是个""空串,空串与Null(空数据)不是一回事,楼主这点弄混了!