sqlite不存在记录则插入数据
生活随笔
收集整理的這篇文章主要介紹了
sqlite不存在记录则插入数据
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
問題:如下圖在Sqlite數(shù)據(jù)庫中存在一張Student表,現(xiàn)需要向表中插入數(shù)據(jù),如果不存在同名記錄則插入,否則不進(jìn)行插入操作。
解答:利用not exists語句,如下:
insert into [Student]([Name], [Age]) select '周俊豪', 21 where not exists (select * from [Student] where [Name]='周俊豪')??執(zhí)行該語句,第一遍執(zhí)行之后會(huì)將 周俊豪 這條數(shù)據(jù)插入,再次執(zhí)行則不再進(jìn)行插入操作了。
?
文章同步更新:http://www.motyer.cn/Files/BlogDetails/sqlite-insert-into-where-not-exists.html
轉(zhuǎn)載于:https://www.cnblogs.com/liujian619/p/sqlite-insert-into-where-not-exists.html
總結(jié)
以上是生活随笔為你收集整理的sqlite不存在记录则插入数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 亲历dataguard的一些经验问答题
- 下一篇: 搭建SpringBoot、Jsp支持学习