SQLite有没有 Exists

csjtxy 2009-04-09 10:44:06
在SQLite中有没有Exists?为什么我用If Exists(select * from Tb where Nid=1)
会报错?
...全文
2032 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
Devil_Ss 2011-05-05
  • 打赏
  • 举报
回复
insert into aa(nickname)
select 't'
where not exists(select * from aa where ids=5)

当aa表中的ids列没有值为5的记录时,将字符串" 't' "插入aa 表的 nickname列中
insert into aa(col1,col2,col3,col4) select num1,'str2','str3',num4
where not exists(select * from aa where col_n=val_n)
honey52570 2009-09-15
  • 打赏
  • 举报
回复
c
zhoulehua 2009-04-14
  • 打赏
  • 举报
回复
不支持,我是在代码中用分支语句操作的。哎,没办法。
结贴罗。
帖子不能编辑 2009-04-13
  • 打赏
  • 举报
回复
快散分吧。
答案都给出来了。
来迟一步。
wwwwb 2009-04-10
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 csjtxy 的回复:]
看来只能在程序中控制了。
[/Quote]
用两条SQL语句可以试试
csjtxy 2009-04-10
  • 打赏
  • 举报
回复
看来只能在程序中控制了。
WWWWA 2009-04-09
  • 打赏
  • 举报
回复
你可以试试:
insert into tt select * from tt where ....
update tt set ... where ...
ACMAIN_CHM 2009-04-09
  • 打赏
  • 举报
回复
SQLite毕竟只是外免费的开源产品,功能上有许多限制。

但你的这种需要可以直接用 INSERT OR REPLACE 语句来实现。 if exists 记录则 update, 不存在则 insert
WWWWA 2009-04-09
  • 打赏
  • 举报
回复
呵呵,不支持,SQLITE没有SP。
csjtxy 2009-04-09
  • 打赏
  • 举报
回复
SQLite 不支持这种写法?

if exists (select ......)
update ......
else
insert into......
WWWWA 2009-04-09
  • 打赏
  • 举报
回复
SQLITE不支持If Exists(select * from Tb where Nid=1)
语法
wwwwb 2009-04-09
  • 打赏
  • 举报
回复
示例:
select * from dd1 where exists(select bh from dd2 where dd1.bh=dd2.bh)
wwwwb 2009-04-09
  • 打赏
  • 举报
回复
3、
SQLITE不支持这种写法
wwwwb 2009-04-09
  • 打赏
  • 举报
回复
1、有
SELECT * FROM TT WEHRE EXISTS(...)
2、你的是T-SQL语法,SQLITE没有SP。
csjtxy 2009-04-09
  • 打赏
  • 举报
回复
急用,期待高手快快来!谢谢

2,209

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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