Created
February 5, 2015 19:04
-
-
Save Reizinixc/6990760c98569fa58f64 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CREATE TABLE t1 ( | |
| id INT UNSIGNED NOT NULL, | |
| name INT UNSIGNED NOT NULL | |
| ); | |
| CREATE TABLE t2 ( | |
| id INT UNSIGNED NOT NULL, | |
| name INT UNSIGNED NOT NULL | |
| ); | |
| INSERT INTO t1 (id, name) VALUES (1, 2), (2, 3), (3, 4), (4, 5); | |
| INSERT INTO t2 (id, name) VALUES (1, 2), (2, 3), (3, 4), (4, 5); | |
| SELECT COUNT(*) < 1 AS isTwoTablesHaveSameData FROM ( | |
| SELECT * | |
| FROM ( | |
| SELECT id, name, -1 AS i FROM t1 s1 | |
| UNION | |
| SELECT id, name, 1 AS i FROM t2 s2 | |
| ) S | |
| GROUP BY id, name | |
| HAVING SUM(i) > 0 | |
| ) T |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment