增删查改:
1.创建数据表:
需要 表名 、 表字段名、定义每个表字段
create table seen( //定义表名id tinyInt auto_increment, // 定义列名以及数据类型,数据是否自动增加title varchar(30) not null,author varchar(30) not null,Primary key(id) // 定义主键)ENGINE=InnoDB DEFAULT charSet=utf8;
2. 删除数据表:
drop table seen; // seen 为表名
3. 插入数据
使用在插入新数据的情况,更改数据用update,不存在有 where 条件的 insert
// insert into (表名) (列名) values (对应每个列的值);insert into data (id, title, author) values (1, "nihao", "yby");select * from data;// 查询所有数据

添加多条数据:
// 假如设置了主键自增,不需要插入的时候加上主键insert into data (title, author)values ("nihao1" , "yby1"), ("nihao2", "yby2");
4. 查找数据
4.1 limit 表示每次查询数量 , offset 表示开始查询位置
// 查找数据可以加上很多条件select * from data where limit = 2 offset = 1;
4.2 id / title 表示要查询的列
select id, title from data where id = 1;
4.3 模糊查询 / 前缀查询
like 语句 中的 “%” 表示任意字符
- 四种匹配方式:

select title from data where title like "nihao%";
4.4 使用 order 进行排序
- order by desc (降序) / 默认升序
select * from data order by id desc;
4.5 使用 between
select * from data where title between "nihao3" and "nihao7";
4.6 Group By 的使用
select id, title from data group by title;

说明 sql 的 严格模式不能兼容这类情况
https://www.cnblogs.com/clschao/articles/9962347.html
ONLY_FULL_GROUP_BY:
对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的,因为列不在GROUP BY从句中。4.7 limit 和 offset 的使用
// limit 2(起始位置, 从起始位置开始的 4 个)select * from data where title like "nihao%" limit 2, 4;
4.8 UNION 用于连接两个以上的 select 语句的结果组合到一个集合中:
select * from union select * from;// 二者查询的结果中的列需要相同
5. update 更改数据
update data set title = "yby2" where id = 3;

// 更改所有数据update data set title = author;
6. delete 删除数据
delete from data where title = "yby1" or title="yby2";

