即向表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)
------解决方案--------------------