Skip to content

Instantly share code, notes, and snippets.

@nextab
Created September 2, 2022 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nextab/6a9b33919ab15e1f59828b4798682dd4 to your computer and use it in GitHub Desktop.
Save nextab/6a9b33919ab15e1f59828b4798682dd4 to your computer and use it in GitHub Desktop.
Dieses kurze "Script" liefert eine Tabelle zurück, in der alle unterschiedlichen Rows von 2 verschiedenen MySQL Tables gelistet sind.
/*
Konkretes Beispiel: Wir hatten die Tabellen "bceup_options_new" sowie "bceup_options_old" und wollten diese beiden miteinander vergleichen. In beiden Tabellen waren die für uns relevanten Spalten die "option_id", der "option_name" sowie die "option_value".
Als Ergebnis haben wir dann eine neue Auflistung aller Zeilen in BEIDEN Tabellen, die sich voneinander unterscheiden.
*/
SELECT option_id,option_name,option_value
FROM (
SELECT option_id, option_name, option_value FROM bceup_options_new
UNION ALL
SELECT option_id,option_name, option_value FROM bceup_options_old
)newTable
GROUP BY option_id, option_name, option_value
HAVING count(*) = 1
ORDER BY option_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment