一、表相关
1.1 增
insert into t(id, name) value(1,'an')
insert into t(id, name) values(1,'an')(2,'bn')
insert into t values(1,'an')(2,'bn')
1.2 删
# 清空表
delete from 表# 会清空表,但不会清空自增字段的offset(偏移量)值
truncate table 表# 会清空表和自增字段的偏移量
# 删除一条数据
delete from 表 where 条件
1.3 改
update 表 set 字段='值' where 条件
update 表 set 字段='值',字段='值' where 条件
1.4 单表查询
select distincr age,sex from t# 自动去重,是age和sex都相同时去重
select age*12 as age from t # 计算age*12的值
# 使用函数
concat
concat_ws()# 第一个参数为分割符
where筛选所有符合条件的行
% 通配符 匹配所有字符
_ 通配符 只匹配一个字符
比较运算符 > < >= <= <> !=
范围 where between 1 end 10 # 包括1和10
范围 where age in (1,2,3,4) # 只能匹配1,2,3