MariaDB FROM
子句用于從表中獲取數(shù)據(jù)。它也被用來連接表,這將在后面章節(jié)中學習。
語法:
SELECT columns_names FROM table_name;
假設要從"students"
表中檢索所有學生信息。參考以下語句中,From
語句的用法 -
SELECT * FROM students;
執(zhí)行上面查詢語句,得到以下結(jié)果 -
MariaDB [testdb]> SELECT * FROM students;
+------------+--------------+-----------------+----------------+
| student_id | student_name | student_address | admission_date |
+------------+--------------+-----------------+----------------+
| 1 | Maxsu | Haikou | 2017-01-07 |
| 3 | JMaster | Beijing | 2016-05-07 |
| 4 | Mahesh | Guangzhou | 2016-06-07 |
| 5 | Kobe | Shanghai | 2016-02-07 |
| 6 | Blaba | Shengzhen | 2016-08-07 |
| 7 | Maxsu | Sanya | 2017-08-08 |
| 8 | Maxsu | Haikou | 2015-11-17 |
+------------+--------------+-----------------+----------------+
7 rows in set (0.00 sec)
從students表中選擇一個特定的列。例如,要選擇student_id
和student_name
列,如下查詢語句 -
SELECT student_id,student_name FROM students;
執(zhí)行上面查詢語句,得到以下結(jié)果 -
MariaDB [testdb]> SELECT student_id,student_name FROM students;
+------------+--------------+
| student_id | student_name |
+------------+--------------+
| 1 | Maxsu |
| 3 | JMaster |
| 4 | Mahesh |
| 5 | Kobe |
| 6 | Blaba |
| 7 | Maxsu |
| 8 | Maxsu |
+------------+--------------+
7 rows in set (0.00 sec)