一个sql语句的写法
1,A表、B表与C表结构相同,字段为USERID,USERNAME,SEX,AGE,STATE
如何A表中有的,B表中没有的数据插入到C表中
[解决办法]
insert Cselect USERID,USERNAME,SEX,AGE,STATEfrom A where not exists(select 1 from B where a.USERID=b.USERID and a.USERNAME=b.USERNAME and a.SEX=b.SEX and a.AGE=b.age and a.STATE=b.STATE)
[解决办法]
INSERT CSELECT userid,username,sex,age,stateFROM aWHERE NOT EXISTS(SELECT 1 FROM b a.userid=userid and a.username=b.usernameAND a.sex=b.sex and a.age=b.age AND a.state=b.state)