如果我下面的查詢:
SELECT 1 FROM emp;
困惑在SELECT 1 FROM
我得到:
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)
我看到有6行與20
和6列在前面:SELECT 1 FROM emp e WHERE 20=e.deptno;
但如何在這些查詢有關?
其實我不認爲這個問題應該被關閉。是的,它顯示了對SQL選擇如何工作的知識缺乏,但它不太定位。 – 2013-04-22 10:50:15