如果我执行以下查询:
SELECT 1 FROM emp;
我得到:
mysql> SELECT 1 FROM emp;
+---+
| 1 |
+---+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
+---+
如果我做:
SELECT 1 FROM emp e WHERE 20=e.deptno;
我得到:
mysql> SELECT 1 FROM emp e WHERE 20=e.deptno;
+---+
| 1 |
+---+
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
| 1 |
+---+
6 rows in set (0.00 sec)
如果我这样做:
mysql> SELECT deptno FROM emp;
+--------+
| deptno |
+--------+
| 10 |
| 10 |
| 10 |
| 20 |
| 20 |
| 20 |
| 20 |
| 20 |
| 20 |
| 30 |
| 30 |
| 30 |
| 30 |
| 30 |
| 100 |
+--------+
15 rows in set (0.00 sec)
20
我看到前面 有 6 行和 6 行:SELECT 1 FROM emp e WHERE 20=e.deptno;
但是这些查询有什么关系呢?