本帖最后由 lyyailxj13 于 2013-01-26 23:00:02 编辑

解决方案 »

  1.   

    insert into A(用户id,用户名,密码)
    select 用户id,用户名,密码
    from  B
    where not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 )
      

  2.   


    请问一下 select 1 from A 这个”1“ 是??
    请原谅我是新手
      

  3.   


    这里exists只是去查询满足条件的记录 如果你select column(表中的列名)、select * 都可以但是select 1 查出来的记录都是常数1 在效率上讲1> column > *
      

  4.   

    insert into A
    select B_id,B_name,B_mi from B
    where not exists(select A_name from A where A_name=B_name )
    可以实现两个表合并,但不知道如何把发现重复的用户id加一位
      

  5.   

    insert into A(用户id,用户名,密码)
    select 用户id,用户名,密码
    from  B
    where not exists(select 1 from A where B.用户id =A.用户id and A.用户名=B.用户名 )
      

  6.   

    insert into A(用户id,用户名,密码)
    select MAX(A.用户id)+1,B.用户名,B.密码
    from A,B
    where not exists(select 1 from A where A.用户名=B.用户名 )
      

  7.   

    楼主 SQL 语法有点差,请参考这个资料吧:
    http://www.w3school.com.cn