当前位置:Gxlcms > 数据库问题 > select判断+insert插入的原子操作 pgsql

select判断+insert插入的原子操作 pgsql

时间:2021-07-01 10:21:17 帮助过:13人阅读

通过sql一步处理

insert into table_name(column1,column2,column3) 
select ‘value1‘,‘value2‘,‘value3‘
where not exists(select column from table_name where id=1);

 

eg:

insert into subscribe_member(openid,msg_title,can_times)
select ‘hhhh‘,‘biaoti‘,1
where not exists(select openid from subscribe_member where id=1);

select判断+insert插入的原子操作 pgsql

标签:sel   tle   column   title   nbsp   exists   member   aot   select   

人气教程排行