Skip to content

Instantly share code, notes, and snippets.

@elenst
Created July 18, 2016 16:54
Show Gist options
  • Save elenst/033b58246b1d1907c948c9b2e7db3495 to your computer and use it in GitHub Desktop.
Save elenst/033b58246b1d1907c948c9b2e7db3495 to your computer and use it in GitHub Desktop.
CREATE TABLE t1 (i1 INT, i2 INT NOT NULL) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1,4),(2,6);
SELECT * FROM t1 AS alias1
WHERE alias1.i1 IN (
SELECT i1 FROM t1 WHERE alias1.i2 IN ( SELECT i2 FROM t1 HAVING i2 <> 7 )
);
DROP TABLE t1;
# Release build:
+------+----+
| i1 | i2 |
+------+----+
| 1 | 4 |
| 2 | 6 |
+------+----+
2 rows in set (0.00 sec)
# Debug build:
Empty set (0.00 sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment