SQL SELECT簡單使用

本次環境使用的是MySQL5.7版

1.搜尋這個table中所有欄位、資料。
SELECT * FROM tableName
mysql> SELECT * FROM Persons;
+----------+----------+-----------+---------+------+
| PersonID | LastName | FirstName | Address | City |
+----------+----------+-----------+---------+------+
|       11 | Lester   | Mark      | No      | No   |
|       12 | Stenson  | Jared     | No      | No   |
|       13 | Walker   | Aidan     | No      | No   |
+----------+----------+-----------+---------+------+
3 rows in set (0.00 sec)
2.根據填入的欄位(cloumn1,cloumn2...)搜尋資料。
SELECT cloumn1,cloumn2... FROM tableName
mysql> SELECT PersonID,LastName,FirstName FROM Persons;
+----------+----------+-----------+
| PersonID | LastName | FirstName |
+----------+----------+-----------+
|       11 | Lester   | Mark      |
|       12 | Stenson  | Jared     |
|       13 | Walker   | Aidan     |
+----------+----------+-----------+
3 rows in set (0.00 sec)

留言

這個網誌中的熱門文章

linux uname指令介紹

PHP - 透過內建curl擷取內容

Ruby入門 - 下載與安裝