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

老是提示select附近有语法错误,我没检查出来,帮我看看吧?谢谢!
 string MyInsert = "insert into QQqun1 (QQ) values (select Distinct(QQ) from QQqun2 a where  not  exists ( select QQ from QQqun1 b where a.QQ=b.QQ) )";
老是提示select附近有语法错误,我没检查出来,帮我看看吧?谢谢!

------解决方案--------------------
insert into QQqun1 (QQ) select qq from 
------解决方案--------------------

insert into QQqun1 (QQ) values (select Distinct(QQ) from QQqun2 a where  not  exists ( select QQ from QQqun1 b where a.QQ=b.QQ) )
改为:
insert into QQqun1 (QQ) select Distinct(QQ) from QQqun2 a where  not  exists ( select QQ from QQqun1 b where a.QQ=b.QQ) 


自己看看有什么区别?
------解决方案--------------------
引用:
 string MyInsert = "insert into QQqun1 (QQ) values (select Distinct(QQ) from QQqun2 a where  not  exists ( select QQ from QQqun1 b where a.QQ=b.QQ) )";
老是提示select附近有语法错误,我没检查出来,帮我看看吧?谢谢!


你那样insert语句是一条一条插入的,但是你的values 那个QQ有多条数据,所以不能那样写
 string MyInsert = "insert into QQqun1 (QQ)  select Distinct(QQ) from QQqun2 a where  not  exists ( select QQ from QQqun1 b where a.QQ=b.QQ)"