MariaDB教程

MariaDB 查询数据

SELECT语句用于从单个或多个表中检索记录。
语法:
SELECT expressions
FROM tables
[WHERE conditions]; 
SELECT语句可以与UNION语句,ORDER BY子句,LIMIT子句,WHERE子句,GROUP BY子句,HAVING子句等一起使用。
SELECT [ ALL | DISTINCT ]
expressions
FROM tables
[WHERE conditions]
[GROUP BY expressions]
[HAVING condition]
[ORDER BY expression [ ASC | DESC ]]; 

从表格中选择所有列

示例:
我们有一个表格" Students",其中有一些数据。因此,从"学生"中检索所有记录。
SELECT * FROM Students; 
输出:
Mariadb选择数据1

从表中选择单个列

您可以使用SELECT语句从表中检索单个列。它有助于您仅检索需要的那些列。
示例:
SELECT student_id, student_name, student_address
FROM Students
WHERE student_id < 5
ORDER BY student_id ASC;
输出:
Mariadb选择数据2
在这里我们从菜单中选择了Student_id,student_name,student_address。表格" students"(其中student_id小于5),我们根据student_id以升序对记录进行排序。

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4