晕,刚才的“”与NULL问题没解决,大家继续来讨论

yan9299 2008-01-16 10:48:03
我的意思是这样的:
写一查询语句,但要TYPE字段的值不等于“”,也不为NULL
我是这样写的
select * from table where type is not null and type is not ""
是错的,大家来指导
...全文
156 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouchunyu 2008-01-16
  • 打赏
  • 举报
回复
select * from table where type is not null and type<>''


这样就不会出错,注意type<>''这个是单引号
kk19840210 2008-01-16
  • 打赏
  • 举报
回复
不好意识更正下

select * from table where isnull(type,'')<>''

一样可以用到索引
yan9299 2008-01-16
  • 打赏
  • 举报
回复
谢谢大家,问题解决
kk19840210 2008-01-16
  • 打赏
  • 举报
回复
select   *   from   table   where   type   is   not   null   and   type   <> '' 
--可以用到索引

select * from table where isnull(type,'')<>'' --使用不到索引
dawugui 2008-01-16
  • 打赏
  • 举报
回复
select   *   from   table   where   type   is   not   null   and   type   <> '' 
kk19840210 2008-01-16
  • 打赏
  • 举报
回复
select   *   from   table   where   isnull(type,'')<>''   
utpcb 2008-01-16
  • 打赏
  • 举报
回复
select *
from table
where type is not null and type<>''
简单
areswang 2008-01-16
  • 打赏
  • 举报
回复
不好意思,1楼应是
select * from table where isnull(type,'') <> ''
sunhonglei2004 2008-01-16
  • 打赏
  • 举报
回复
没有看明白楼主的意思

select * from table where type='' and type is not null ??/
-狙击手- 2008-01-16
  • 打赏
  • 举报
回复
select       *       
from table
where isnull(type,'') <> ''
一者仁心 2008-01-16
  • 打赏
  • 举报
回复
select * from table where type is not null and type != ""
-狙击手- 2008-01-16
  • 打赏
  • 举报
回复
select   *  
from table
where type is not null and type is not ''
areswang 2008-01-16
  • 打赏
  • 举报
回复
select * from table where isnull(type,'')<>""

34,837

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧