select b.* from a,b
where a.id=b.id
and (a.name<>b.name
or a.address<>b.address
or a.tel<>b.tel
)ps:王五的地址并没改变

解决方案 »

  1.   

    我上面把姓名改变也放进去了,也许不用,那就改成select b.* from a,b
    where a.id=b.id
    and (a.address<>b.address
    or a.tel<>b.tel
    )
      

  2.   

    select * from (select B.id,B.name, B.address,B.tel from A,B where A.id = B.id and A.name = B.name and (A.address <> B.address or A.tel <> B.tel))C
      

  3.   

    declare @ta table(id varchar(10),name varchar(10),address varchar(10),tel varchar(15))
    insert @ta
    select '001',   '张三',    '南京',      '137' union all
    select '002',   '李四',    '南京',      '138' union all
    select '003',   '王五',    '南京',      '139' 
    declare @tb table(id varchar(10),name varchar(10),address varchar(10),tel varchar(15))
    insert @tb
    select '001',   '张三',    '南京',      '139' union all
    select '002',   '李四',    '南京',      '138' union all
    select '003',   '王五',    '上海',      '139'select * from @tb  where checksum(*) not in(select checksum(*) from @ta)/*结果
    id         name       address    tel             
    ---------- ---------- ---------- --------------- 
    001        张三         南京         139
    003        王五         上海         139
    */