05-第五章-单表查询
51-条件查询
71-今日内容
72-sql语言删除数据
select * from goods;
delete from 表名 where 条件
delete from goods where id=4;
注意:如果删除执行的数据,务必给出限定条件,否则会删除所有的数据
73-sql语句查询数据基本查询
select from 表名;
select * from goods;
select goodsName,price from goods;
只需要在查询所有数据的基础上,修改的位置,多个字段用逗点隔开
起别名
select goodsName as ‘商品名称’,price as ‘价格’ from goods;
使用as关键字,后跟别名就可以了
select goodsName ‘商品名称’,price ‘价格’ from goods;
熟练之后 as关键字也可以省略
去重:根据所给的字段,将字段当中数据相同的数据合并保留
需求:当前表当中一共有几家公司
select distinct(company) from goods;
select goodsName as ‘商品名称’ ,price as’价格’ from goods;
select * from goods where price
74-sql语句查询数据条件查询比较运算符,逻辑运算符
《》不等于!=
select *from goods where price=30;
注意where关键后侧的字符串数据,必须给引号,否则会报错
75-sql语句查询数据条件查询模糊查询
查询全部一次性口罩的商品信息
select * from goods
模糊查询
like(字符:%匹配任意的多个字符)
where 字段 like ‘%信息’
select * from goods where remark like ‘%一次性口罩’;
select * from goods where remark like ‘%一次性口罩’;
76-sql语句查询数据条件查询范围查询
select * from goods;
select * from goods where between 起始值 and结束值;表示一个连续的范围
select * from goods where price between 30 and 100;
in表示在某个不连续的范围内
in(条件1,条件2)
select * from goods where compnay in (‘某东’,‘x包’);
select * from goods where company(‘某东’,x包’);
77-sql语句查询数据条件查询空判断
需求7 : 空判断
null与’‘是不同的
注意:null与’'不是一个意思,null代表空,’‘空字符,空格,制表符(tab)
select * from goods where remark is null;
以下数据当中描