compare differences between two tables in mysql

后端 未结 6 1496
北荒
北荒 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:49

    I found another solution in this link

    SELECT MIN (tbl_name) AS tbl_name, PK, column_list
    FROM
     (
      SELECT ' source_table ' as tbl_name, S.PK, S.column_list
      FROM source_table AS S
      UNION ALL
      SELECT 'destination_table' as tbl_name, D.PK, D.column_list
      FROM destination_table AS D 
    )  AS alias_table
    GROUP BY PK, column_list
    HAVING COUNT(*) = 1
    ORDER BY PK
    

提交回复
热议问题