聚合函数 count,max,min,avg,sum... select count (*) from T_Employee select Max(FSalary) from T_Employee 排序 ASC升序 DESC降序 select * from T_Employee order by Fage 先按年龄降序排列.如果年龄相同,则按薪水升序排列 select * from T_Employee order by FAge DESC,FSalary ASC order by 要放在 wh
use StudentManageDB go select StudentName,StudentAddress from Students where StudentAddress like '天津%' select StudentName,StudentAddress from Students where StudentName like '%小%' select * from ScoreList select StudentName,StudentAddress,Birthday fro
第二章 mysql 一.模糊查询 like 1. 字段 like '河北省%' %代表任何N个字符 2 字段 like '河北省____' _代表任意1个字符 二.IN 语法:SELECT 字段列1,字段2 ,…FROM 表名 WHERE 字段x IN ( 值1,值2,值3…) 三.排序 语法:select 字段1, 字段2, ... from 表名 where 条件 order by 字段 [asc|desc] asc :升序 desc :降序 默认是升序asc SELECT * FROM s
--exists 结合 if else 以及 where 条件来使用判断是否有数据满足条件 select * from Class where Name like '%[1-3]班' if (not exists(select * from Class where len(Name)>=5)) select '满足条件' else select '不满足条件' --in not in 用来做范围判断 select * from Student where ClassId in(select Id
首先初始化表和数据 create table t_student( Id INT, Name varchar(), Score int, ClassId INT ); insert into t_student values (,,); insert into t_student values (,,); insert into t_student values (,,); insert into t_student values (,,); insert into t_stud
mysql 分组和聚合函数 Mysql 聚集函数有5个: 1.COUNT() 记录个数(count(1),count(*)统计表中行数,count(列名)统计列中非null数) 2.MAX() 最大值 3.MIN() 最小值 4.AVG()平均值 5.SUM() 求和 聚集函数常常和分组一起工作. 1.创建分组 select name, max(age) from stu group by name; 2.过滤分组 select name, max(age) from stu group by