数据库a(int a1,int a2 ,varchar(50) a3)与
  数据库b(int b1,int b2 ,varchar(50) b3)
  查询出a数据库中a1=b1的记录同时将b3更新a3所返回表.比如
------------a表----------------------------
1 11 "a"
2 22 "b"
3 33 "c"------------b表----------------------------
4 11 "aa"
2 22 "bb"
5 33 "cc"结果------------c表------------------------
2 22 "bb"
最好是SQL语句,同时修改只是在内存中进行,不可以修改两个表.

解决方案 »

  1.   

    select b.b1,b.b2,b.b3 as a3
    from a,b
    where a.a1=b.b1不知道你说的是不是这个意思
      

  2.   

    select * from
    (select a.a1,b.b2 from a,b where a.a1=b.b1)
    into c
      

  3.   

    查询出a数据库中a1=b1的记录
    同时将b3=a3
      

  4.   

    --1
    select a.* , b.* from a , b where a.a1 = b.b1--2
    update c set c3 = b.b3
    from c , a , b
    where c.c1 = a.a1 and a.a1 = b.b1
      

  5.   

    update c set c3 = b.b3 from c , a , b where c.c1 = a.a1 and a.a1 = b.b1
      

  6.   

    select  b.* 
    into c  --结果生成表c
    from a , b
    where a.a1 = b.b1update b  --用a表更新b表
    set b.b3=a.a3
    from a
    where a.a1 = b.b1
      

  7.   

    update a 
    set a.a3=b.b3 
    from b 
    where a.a1=b.b1select a.* 
    into c 
    from a,b 
    where a.a1=b.b1
      

  8.   

    相当于查表b中满足条件的数据?select b.* 
    from a,b
    where a.a1 = b.b1