Select 查询语句
语法:八宝饭的做法SELECT [ALL|DISTINCT] <目标列表达式> [AS 列名]
[,<目标列表达式> [AS 列名] ...] FROM <表名> [,<表名>…]
[WHERE <条件表达式> [AND|OR <条件表达式>...]
[GROUP BY 列名 [HAVING <条件表达式>>
[ORDER BY 列名 [ASC | DESC>
解释:[ALL|DISTINCT] ALL:全部;春节儿歌 DISTINCT:不包括重复行
<目标列表达式> 对字段可使用AVG、COUNT、SUM、MIN、MAX、运算符等
<条件表达式>
查询条件 谓词
比较 =、>,<,>=,<=,!=,<>,
确定范围 BETWEEN AND一年级古诗、NOT BETWEEN AND
确定集合 IN、NOT IN
字符匹配 LIKE(“%”匹配任何长度,“_”匹配一个字符)、NOT LIKE蓝牙耳机怎么打开
空值 IS NULL、IS NOT NULL
子查询 ANY、ALL、EXISTS
集合查询 UNION(并)、INTERSECT(交)、MINUS(差)西安旅游攻略
多重条件 AND、OR、福开头的成语NOT
<GROUP BY 列名> 对查询结果分组
[HAVING <条件表达式>] 分组筛选条件
[ORDER BY 列名 [ASC | DESC> 对查询结果排序;ASC:升序 DESC:降序
例1: lect student.sno as 学号, student.name as 姓名, cour as 课程名, score as 成绩可转换公司债 from score,student where student.sid=score.sid and score.sid=:sid
例2:lect student.sno as 品德教育学号, student.name as 姓名,AVG(score) as 平均分 from score,student where student.sid=score.sid and student.class=:class and (term=5 or term=6) group by student.sno, student.name having count(*)>0 order by 平均分 DESC
例3:lect * from score where sid like '9634'
例4:lect * from student where class in (lect class from student where name='陈小小')