Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
同じ構造のテーブルが 2 つあります。現在、そのうちの 1 つはライブ テーブルの古いダンプです。
古いダンプと比較して、ライブテーブルで異なるまたは新しいすべての行を抽出する必要があります。
すべての行を選択してこれを行い、それを PHP と比較する方法は知っていますが、これは効果的な解決策ではありません。
これを簡単な方法で作成する方法を知っている人はいますか?
SELECT newtable.* FROM newtable LEFT JOIN oldtable USING (id) WHERE oldtable.id IS NULL /* new rows */ OR newtable.col1 != oldtable.col1 OR newtable.col2 != oldtable.col2 OR newtable.col3 != oldtable.col3 ...