Grouping
SELECT
COUNT (*) sum,
Book_name,
Bokk_author
From
Book
GROUP by
Bokk_author
Having
Sum > 3;
Simple difference between drop truncate delete (to be perfected)
DORP table structure will be deleted, all deleted
Truncate clears the table data, deletes the entire data
Delete Deletes data and deletes some functions with delete
TRUNCATE TABLE author
DROP TABLE Test
Delete from author where author_name = "HHQ"
Union\union All Union query
The Union and UNION ALL keywords combine two result sets into one, and two tables have the same number of columns
Union can be de-weighed, union all shows all
Select Bokk_author from book union ALL select Author_name from author;
Select Bokk_author from book Union select Author_name from author;
Transaction processing
There are two main methods of MySQL transaction processing:
1, with Begin,rollback,commit to achieve
Begin a transaction
ROLLBACK TRANSACTION Rollback
Commit TRANSACTION Acknowledgement
Begin
Delete from author;
Select from author;
ROLLBACK;
SELECT from author;
COMMIT;
2. Change MySQL auto-commit mode directly with Set
Set autocommit=0 prohibit auto-commit
Set autocommit=1 turn on auto-commit
Common database statements (4)