insert into `good` (id,good_name,price) values(11,'苹果手机',5000);
-- 表名 列名 列名 列名 值
update good set price = price + 1000 where good_name = '苹果手机';
delete from good where good_name = '苹果手机';
select [distinct] *|{column1,column2,....} from table_name;
-- 统计每个学生的总分
select `name`,(chinese+english+math) from student;
-- 给每个学生的总成绩加10分
select `name`,(chinese+english+math+10) from student;
-- 使用别名表示学生的总成绩
select `name` as '名字',(chinese+english+math) as total_score from student;
比较运算符
> < <= >= = <> != -- 大于,小于,大于(小于)等于,不等于
between ... and ... -- 显示在某一区域的值
in(set) -- 显示在in列表中的值,例如,in(100,200) 这个set是个集合,不是表示区间
like '张pattern'
not like '' -- 模糊查询
is null -- 判断是否为空
逻辑运算符
and -- 多个条件同时成立
or -- 多个条件任一成立
not -- 不成立,例如:where not (salary>100);
select * from student where (chinese+english+math) > 200 and math< chinese and `name` like '韩%';
-- 这个 韩% 表示是以韩开头的字符串,无论韩后面有多少个字符都可以。
-- 韩_ 表示是以韩开头的字符串,但是 韩后面只能有一个字符。
select * from student where english between 80 and 90;
select column1,column2,... from tablename order by column asc|desc;
select * from student order by math;-- 默认是升序
select * from student order by math desc -- 按照math成绩降序排列
select `name`,(chinese+math+english) as total_score from student order by total_score;
-- 对总分按照升序进行排列
select `name`,(chinese+math+english) as total_score from student order by total_score desc;
-- 对总分按照降序进行排列