首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

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

2012-06-07 
Postgresql中的判断问题(求教)有2张表。a和b在向b表做insert时:如果a表的id内容并不存在于b表中时做insertS

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' )

热点排行