SQL SERVER 数据库中bit字段的查询

cql0007 2003-11-05 09:04:38
在SQL SERVER数据库中,有一字段,是BIT型的,是用来做一行记录的标识的.刚刚开始时都是空的<NULL>,我想读完一条记录的时候,然后再将该记录标记为已读,将该字段赋值为1,我的代码如下:
sql = "select * from Coordinate where isRead <> '1' OR isRead = NULL "
set rs = Server.createObject("ADODB.RecordSet")
rs.open sql,conn,1,3
do while NOT rs.EOF
x = rs("CoordinateX")
y = rs("CoordinateY")
vsl = rs("VSL")
rs.update
rs("isRead") = "1"
rs.update

rs.moveNext
loop
%>
''''''''''''
关键是这个SQL语句,我怎么写都不对:
sql = "select * from Coordinate where isRead <> '1' OR isRead = NULL "
如果我的isRead(bit型)字段是0,那isRead<>'1'可以成立,能找出来,但如果那个字段是空的,也就是没写过任何数据的<NULL>时,用上面的查询SQL就什么都查不到了,该如何写?谢谢!
...全文
174 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cql0007 2003-11-05
  • 打赏
  • 举报
回复
ASP版人气就是旺啊,多谢各位了,我用了summercat(飘轩)的两种方法都可以了.

再问一句:为什么直接用过isRead<>'1'却不行了,一定还要加个OR了?
lovehwq21 2003-11-05
  • 打赏
  • 举报
回复
来晚了,呵呵……
用summercat(飘轩) 的第一个方法就OK了
phoenix8122 2003-11-05
  • 打赏
  • 举报
回复
isRead <> '1'包含了isRead = NULL
phoenix8122 2003-11-05
  • 打赏
  • 举报
回复
sql = "select * from Coordinate where isRead <> '1'"
yonghengdizhen 2003-11-05
  • 打赏
  • 举报
回复
select * from Coordinate where ISNULL(isRead,0)<>1
summercat 2003-11-05
  • 打赏
  • 举报
回复
or
sql = "select * from Coordinate where isRead <> '1' OR isRead=''"
summercat 2003-11-05
  • 打赏
  • 举报
回复
sql = "select * from Coordinate where isRead <> '1' OR isRead is NULL "

28,391

社区成员

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

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