鍍金池/ 教程/ 數(shù)據(jù)庫/ MariaDB From子句
MariaDB比較運算符
MariaDB查詢數(shù)據(jù)
MariaDB Like子句
MariaDB Sum()函數(shù)
MariaDB過程
MariaDB限制返回記錄
MariaDB Count()函數(shù)
MariaDB更新數(shù)據(jù)
MariaDB導出數(shù)據(jù)
MariaDB Intersect運算符
MariaDB函數(shù)
MariaDB Min()函數(shù)
MariaDB創(chuàng)建數(shù)據(jù)庫
MariaDB Avg()函數(shù)
MariaDB刪除數(shù)據(jù)
MariaDB條件
MariaDB功能特點
MariaDB創(chuàng)建表
MariaDB左外連接
MariaDB Union運算符
MariaDB安裝
MariaDB選擇數(shù)據(jù)庫
MariaDB Max()函數(shù)
MariaDB Where子句
MariaDB右外連接
MariaDB內(nèi)連接
MariaDB截斷表
MariaDB Order By子句
MariaDB教程
MariaDB正則表達式
MariaDB Union All運算符
MariaDB Distinct子句
MariaDB修改表
MariaDB刪除表
MariaDB插入數(shù)據(jù)
MariaDB From子句
MariaDB刪除數(shù)據(jù)庫
MariaDB簡介
MariaDB數(shù)據(jù)類型

MariaDB From子句

MariaDB FROM子句用于從表中獲取數(shù)據(jù)。它也被用來連接表,這將在后面章節(jié)中學習。

語法:

SELECT columns_names FROM table_name;

示例1:

假設要從"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)

示例2:

從students表中選擇一個特定的列。例如,要選擇student_idstudent_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)