MariaDB FROM
子句用于从表中获取数据。它也被用来连接表,这将在后面章节中学习。
语法:
SELECT columns_names FROM table_name;
假设要从"students"
表中检索所有学生信息。参考以下语句中,From
语句的用法 -
SELECT * FROM students;
执行上面查询语句,得到以下结果 -
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;
执行上面查询语句,得到以下结果 -
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)
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
长按识别二维码并关注微信
更方便到期提醒、手机管理