这个SQL语句怎么写???简单

zc1972 2003-12-12 11:19:08
如何选取某字段非空的记录集??
SELECT * FROM xx where hf<>"" ORDER BY sj DESC

除了这个 hf<>"" ,还有什么判断非空的写法?
...全文
27 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
zc1972 2003-12-12
  • 打赏
  • 举报
回复
全句是
Set recordset1 = Server.CreateObject("ADODB.RecordSet")
exec= "SELECT * FROM xx where hf<>'' or hf is not null ORDER BY sj DESC"
recordset1.Open exec,my,1,1

============================
但通不过。。。
zc1972 2003-12-12
  • 打赏
  • 举报
回复
为什么我这样写通不过,我是SQL SERVER库。。
sql="SELECT * FROM xx where hf<>'' or hf is not null ORDER BY sj DESC"

sql="SELECT * FROM xx where hf is not null ORDER BY sj DESC"
能通过。。。
hf是备注型字段。
zc1972 2003-12-12
  • 打赏
  • 举报
回复
你用的是什么数据库?
SELECT * FROM xx where hf<>"" or hf is not null ORDER BY sj DESC
这个是用在SQL SERVER里的

如果是ACCESS,可以直接用你的那句

isEmpty是VBS的函数。
Primer2002cn 2003-12-12
  • 打赏
  • 举报
回复
SELECT * FROM xx where (hf<>"") or (hf is not null) ORDER BY sj DESC
poolnet 2003-12-12
  • 打赏
  • 举报
回复
SELECT * FROM xx where hf<>"" and (hf is not null) ORDER BY sj DESC
shleo 2003-12-12
  • 打赏
  • 举报
回复
"SELECT * FROM xx where hf<>'' or hf is not null ORDER BY sj DESC
"
或者"SELECT * FROM xx where hf<>"""" or hf is not null ORDER BY sj DESC
"
有些要用null
"SELECT * FROM xx where hf is not null ORDER BY sj DESC"
选出来的字段比较是否为空为
isnull()
zc1972 2003-12-12
  • 打赏
  • 举报
回复
hf<>"" 这样写对不对???
是不是还有个 isEmpty 写法???
它们联合起来怎么写?这个有错误。。。

SELECT * FROM xx where hf<>"" or hf is not null ORDER BY sj DESC

Primer2002cn 2003-12-12
  • 打赏
  • 举报
回复
结贴吧
qwater 2003-12-12
  • 打赏
  • 举报
回复
is not null
licrazy5201 2003-12-12
  • 打赏
  • 举报
回复
看错了,是非空,我写成为空了,不好意思,
SELECT * FROM xx where hf is not null ORDER BY sj DESC
luluso 2003-12-12
  • 打赏
  • 举报
回复
select * from xx where hf not null order by sj desc
licrazy5201 2003-12-12
  • 打赏
  • 举报
回复
SELECT * FROM xx where hf is null ORDER BY sj DESC
a_zhe_20 2003-12-12
  • 打赏
  • 举报
回复
SELECT * FROM xx where hf is not NULL ORDER BY sj DESC
hgllucky 2003-12-12
  • 打赏
  • 举报
回复
up
zc1972 2003-12-12
  • 打赏
  • 举报
回复
这个xx是个备注型text16字段,我刚才把它改成varchar,上面语句可以通过。为什么?
还有表中有几个记录的xx字段为""(空)值,但却被当成有值了。。。就是hf<>'' 没有起作用。。。 这又是怎么回事???
Struggling 2003-12-12
  • 打赏
  • 举报
回复
try:

Set recordset1 = Server.CreateObject("ADODB.RecordSet")
exec= "SELECT * FROM xx where hf<>'' or hf is not null ORDER BY sj DESC"
recordset1.Open exec,my,1,3
zc1972 2003-12-12
  • 打赏
  • 举报
回复
up~~~~~~~~~~~~~~~~~~~~~~~~~没人明白吗???
shleo 2003-12-12
  • 打赏
  • 举报
回复
…………
你怎么又比较是否为''又比较 is not null
只会出现其中的一种情况的

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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