if not exists(
select
*
from
table1
where
mid=
'aa'
)
INSERT
INTO
table1(mid,
name
,msg)
VALUES
(
'aa'
,
'bb'
,
'cc'
)
参考例子:
if not exists (select * from mobile_menu_settings where menu_code = 'workload') INSERT INTO [dbo].[mobile_menu_settings]([menu_code], [menu_name], [is_enabled], [is_enabledDept], [imgName], [pageUrl], [menuType], [serialNo]) VALUES ('workload', '医嘱执行记录', 0, NULL, 'mdi-format-indent-increase', 'workload.html', 3, 7);
数据已存在时,执行不会插入数据
还没有评论,来说两句吧...