1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| mysql> create table t1 (c int);
Query OK, 0 rows affected (0.09 sec)
mysql> insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
Query OK, 9 rows affected (0.05 sec)
Records: 9 Duplicates: 0 Warnings: 0
mysql> create table t2 (c2 int);
Query OK, 0 rows affected (0.06 sec)
mysql> insert into t2 values (1),(2),(3),(9);
Query OK, 4 rows affected (0.03 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> select c
-> from t1
-> where exists (select 1
-> from t2
-> where t2.c2 = t1.c);
+------+
| c |
+------+
| 1 |
| 2 |
| 3 |
| 9 |
+------+
4 rows in set (0.05 sec)
mysql> select version();
+------------+
| version() |
+------------+
| 5.5.16-log |
+------------+
1 row in set (0.02 sec)
mysql> |
Partager