分组 SELECT count(*) sum, book_name, bokk_author FROM book GROUP BY bokk_author HAVING sum > 3;

drop truncate delete 的简单区别(待完善)

Dorp 表结构都会删掉,全部删掉 Truncate 清空表数据,删除整个数据 Delete 删除数据,删除部分职能用delete

truncate table author drop table test delete from author where author_name = "hhq"

Union\union all 联合查询 union和union all关键字都是将两个结果集合并为一个,两个表的列数要相同 Union 可以去重,union all 显示所有

select bokk_author from book union all select author_name from author; select bokk_author from book union select author_name from author;

** 事务处理** Mysql事务处理主要有两种方法: 1、用begin,rollback,commit来实现 Begin 开始一个事务 Rollback事务回滚 Commit事务确认

begin; delete from author; select * from author; ROLLBACK; SELECT * from author; COMMIT; 2、直接用set改变mysql的自动提交模式 Set autocommit=0 禁止自动提交 Set autocommit=1 开启自动提交