1.基础查询where 高级条件查询Where子句 SELECT empno,ename,sal,hiredate FROM t_tmp WHERE deptno=10 AND (sal+IFNULL(comm,0)*12)>=15000 AND DATEDIFF(NOW(),hiredate)/365>=20; Where 中搭配四种运算符 算数运算符:+ - * / % 比较运算符:> >= < <= = != IN IS NULL, IS NOT NULL,BET…
python进阶09 MySQL高级查询 一.筛选条件 # 比较运算符 # 等于:= 不等于:!= 或<> 大于:> 小于:< 大于等于>= 小于等于:<= #空:IS NULL 非空:IS NOT NULL # NULL 的查询比较特殊,只有在条件里加上IS NULL 或IS NOT NULL 才能够查询出NULL #逻辑运算符 #与:AND 或:OR 非:NOT 范围查询 BETWEEN a AND b SELECT * FROM students WHERE ag…
01.SQL高级查询_排序 1.排序语句:order by 排序字段名 asc(默认的-升序) / desc(降序); 2.例如:查询所有服装类商品,将查询结果以价格升序排序: select * from product where category_id = '服装' order by price asc; 3.可以对数值类型.日期类型.英文字母的字符串字段进行排序: 4.对多列进行排序: 1).需求:查询所有的服装类商品,按价…
高级查询: 一:多表连接 1.select Info.Code,Info.Name,Nation.Name from Info,Nation where Info.Nation = Nation.Code 查几张表就就输出几张表,查那个条件就输出那个条件 列的查询 select * from Info,Nation 全部输出4x4 2.join连接 select * from Info join Nation on Info.Nation = Nation.Code 筛选输出数据 二:多表联合…
高级查询:1.连接查询select * from Info,Nation #这是两个表名,中间用逗号隔开形成笛卡尔积select * from Info,Nation where Info.nation=Nation.code select Info.code,Info.name,Info.sex,Nation.name as '民族',Info.birthday from Info,Nation where Info.nation=Nation.code select * from Info…
高级查询: 1.连接查询 select * from Info,Nation #得出的结果称为笛卡尔积select * from Info,Nation where Info.Nation = Nation.Code join on连接 select * from Info join Nation #join连接select * from Info join Nation on Info.Nation = Nation.Code 2.联合查询 select Code,Name from Info…
1 GROUP_CONCAT mysql> SELECT student_name, -> GROUP_CONCAT(test_score) -> FROM student -> GROUP BY student_name; Or: mysql> SELECT student_name, -> GROUP_CONCAT(DISTINCT test_score -> ORDER BY test_score…
1. mysql 支持三种类型的连接查询: on 后面跟的是关联条件 内连接查询 select s.name,c.name from students as s inner join classes as c on s.cls_id=c.id; 左连接查询 select s.name,c.name from students as s left join classes as c on s.cls_id=c.id; 右连接查询 select s.name,c.name from students…
day04数据库 昨日知识点回顾 1.单表操作 1.单表的操作 条件查询的优先级别: where > group by >having > order by > limit; 分组:group by select gender count(id) from xxx group by gender; 过滤筛选:having select gender count(id) from xxx group by gender having count(id)>13; 排序:order…