救命啊,我改怎么写。

liushui05 2004-04-21 06:12:21
数据库中的一个字段b是TEXT类型的,我象通过查询语句将b中内容不为空的记录
显示我这样写:

select * from the_table where isnull(b,1)=0
提示说int与text不兼容

我按照下面的写法:
select * from theable where b is not null

提取的又是所有记录,郁闷啊~

这到底是怎么回事呢?我应该怎么写呢? 请高手帮忙了。问题解决立马发分。
...全文
113 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdnweii 2004-04-22
  • 打赏
  • 举报
回复
select * from theable where b is not null and b<>''
pbsql 2004-04-22
  • 打赏
  • 举报
回复
select * from theable where b is not null and b<>''
liushui05 2004-04-22
  • 打赏
  • 举报
回复
pbsql(风云) 你说的是,数据库中是非NULL,可是里面确实没有什么东西的啊~~我应该怎么写的呢?
pbsql 2004-04-22
  • 打赏
  • 举报
回复
应该这样才对:
select * from theable where b is not null and b not like ''
birchsilver 2004-04-22
  • 打赏
  • 举报
回复
--你试试这样可以吗?

create table aa
(
int int identity not null ,
info text ,
notes varchar(50)
)


insert into aa(info)
select 'adsfasdfadfasdfadsfasdfasdf zlj'

insert into aa(notes)
select 'Second'

insert into aa(notes)
select 'Third'

insert into aa(info,notes)
select '','Forth'

select * from aa
where info is not null
and datalength(info) != 0
liushui05 2004-04-22
  • 打赏
  • 举报
回复
不行的啊同志们,一加上b<>''就会出现提示说:不能比较或排序text类型的数据。郁闷~
pbsql 2004-04-21
  • 打赏
  • 举报
回复
select * from the_table where isnull(b,1)=0
text、1与0比较当然不兼容啦

select * from theable where b is not null
提取的又是所有记录,因为所有记录的b都有值(非null),所以当然是所有值啦
csdnweii 2004-04-21
  • 打赏
  • 举报
回复
select * from theable where b is not null
没有错啊

测试:
select * from text
id
-----------
sdf
null
null
55

SELECT * FROM text WHERE (id IS not NULL)
id
-----------
sdf
55
yidengjiang 2004-04-21
  • 打赏
  • 举报
回复
我以前是用b!='' 或者b<>''
quicklight 2004-04-21
  • 打赏
  • 举报
回复
b<>''

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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