日期:2014-05-17  浏览次数:20696 次

求一sql写法~
即向表TRA_TEACHERS中插入新的数据。ID存在则不执行。类似这种写法通不过。。求助
insert into tra_teachers(ID,NAME,SEX,DEPARTMENT,TEACHER_NO,PID) select '1','2','3','4','5','6' where '1' not in(select ID from tra_teachers)

------解决方案--------------------
你后面的select语句没有from关键字啊:
SQL code
insert into tra_teachers(ID,NAME,SEX,DEPARTMENT,TEACHER_NO,PID) select '1','2','3','4','5','6' from dual 
where '1' not in(select ID from tra_teachers)

------解决方案--------------------
用exists 
insert into a select 1,'c' from dual where not exists (select id from a where id=2)
------解决方案--------------------
探讨

恩。。加上 from dual 问题解决了。。不知道dual指什么啊~