compare differences between two tables in mysql

后端 未结 6 1491
北荒
北荒 2020-11-30 17:07

Same as oracle diff: how to compare two tables? except in mysql.

Suppose I have two tables, t1 and t2 which are identical in layout but which may contain

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-30 17:35

     select t1.user_id,t2.user_id 
     from t1 left join t2 ON t1.user_id = t2.user_id 
     and t1.username=t2.username 
     and t1.first_name=t2.first_name 
     and t1.last_name=t2.last_name
    

    try this. This will compare your table and find all matching pairs, if any mismatch return NULL on left.

提交回复
热议问题