SQL语言的增删改查
select(查), update(改), delete(删), insert into(增)
select * from table_name 获取表中所有字段
select id, name, sex from table_name 获取表中的id,name,sex字段
select count(id) count from table_name 获取表中列表总数量 count(*/1/id 都行) 第二个count是作为别名
select * from table_name limit 0, 10 分页
select * from table_name where id = 1 获取id为1的数据
select * from table_name where id = 1 and name='Job' 获取id为1 name为Job的数据 并联条件用and连接
select * from table_name where name LIKE '%Job%' 模糊查询
select * from table_name where create_time between '${startTime}' and '${endTime}' order by create_time DESC 选择时间范围 按照逆序排
update table_name set age = 18 where id = 1 根据id修改一条数据
update table_name set age = 18 where id != 1 根据id修改多条数据
update table_name set age = 18 where id in (1, 2, 3) 根据id修改多条数据
update table_name set show = 0 where id != 1;update table_name set show = 1 where id = 1 只有id为1的数据show为1 其余为0。两条语句用分号隔开(大神说sql语句不要写两条:1.版本不兼容 2.不安全,会有sql注入的危险)
delete from table_name where id = ? 删除一条数据
insert into table_name (name, age, create_time) values ('Bob',18,now()) 插入一条数据
insert into table_name (name, age, create_time) values ('Bob',18,now()),('Jack',20,now()) 插入多条数据