Postgresql中的判断有关问题(求教)

Postgresql中的判断问题(求教)

有2张表。a和b

在向b表做insert时:

如果a表的id内容并不存在于b表中时做insert

SQLSERVER中很好实现并已实现

但是在Postgresql中尝试了好几次都没实现过

求高手赐教

SQLSERVER中:

if(select count(*) from b where id=’1′)=0

insert into b values(‘1′,’11’)

可直接正确执行

Postgresql中如何实现呢?




insert into b select distinct ‘1’,’11’from b where 0=(select count(*) from b where id=’1′ )

Postgresql中的判断有关问题(求教)

相关文章:

你感兴趣的文章:

标签云: