DBMS中的SELECT语句及其子句
select语句用于根据条件从数据库中获取所需的数据(如果有)。该数据以表格的形式返回。
select语句的基本语法是-
Select column 1, column 2 ... column N From table_name
select语句的一个示例是-
<学生>
科目
查询-
Select Student_Name From Student
此查询产生以下结果-
Select语句中的子句
上面给出的select语句示例很简单,但实际上没有用。因此,还有许多其他与select语句关联的子句使它更有意义。其中一些是-
哪里
where子句用于过滤数据,即它返回满足特定条件的信息。例如-
Select Student_Name From Student Where Student_Marks >50
该查询将返回以下结果:
通过...分组
这通常与聚合函数一起使用,以根据列的值对结果集进行分组。例如-
Select Count (Student_Number), Student_MajorSubject From Student Group by Student_MajorSubject
该查询将返回以下结果-
有
这与GroupBy子句一起使用,因为聚合函数无法使用Where子句。例如-
Select Count(Student_number), Student_MajorSubject From Student Group by Student_MajorSubject Having Count(Student_Number) > 2
该查询将返回以下结果-
排序依据
orderby关键字用于按升序或降序对结果进行排序。默认情况下,假定顺序为升序。例如-
Select Student_Name From Student Where Student_Marks>50 Order by Student_Marks
该查询将返回以下结果-
热门推荐
10 对患者生日祝福语简短
11 结婚祝福语简短装备
12 周岁祝福语学生文案简短
13 订婚领证祝福语简短精辟
14 导师获奖祝福语大全简短
15 新婚购房祝福语简短精辟
16 牛年祝福语简短的爱人
17 送芒果的祝福语简短
18 送给学长毕业祝福语简短