使用SQL Server CE;仅当不存在时才可以插入? [英] Using SQl Server CE; Possible to Insert Only If Not Exists?

查看:28
本文介绍了使用SQL Server CE;仅当不存在时才可以插入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试验证一个简单的 1 字段表,以确定在插入重复项之前是否存在记录.

I'm trying to verify a simple 1 field table to determine if a record exists before inserting a duplicate.

if not exists (select * from url where url = ...)
insert into url...

有人可以帮忙吗?

推荐答案

您的代码示例将在完整版的 SQL 中运行,或者您可以重新排列为以下内容:

Your code example will run in the full version of SQL, or you could rearrange to the following:

insert into url
select 'myvalue'
where not exists (select * from url where url = 'myvalue')

这篇关于使用SQL Server CE;仅当不存在时才可以插入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆