Distinct can remove duplicate lines, query time with SELECT DISTINCT * from ...;
Unique is one of the integrity constraints in MySQL and adds a unique constraint if the value of a column needs to be unique.
The purpose of creating a unique index is not to increase access speed, but to avoid duplication of data. A unique index can have more than one but the value of the indexed column must be unique, and the value of the indexed column allows for a null value. If you can determine that a data column will contain only values that are different from each other, you should use the keyword unique when creating an index for that data column and define it as a unique index.
* The difference between truncate and delete:
* Truncate DELETE data, delete entire table first. Create a new empty table again. Efficiency
* Delete Deletes data, one by one deleted. (*****)
* Group BY group (used together) conditional filtering needs to be having, cannot use where
Exercise: After classifying the items in the order form, the total price of each type of item is displayed.
Select Product,count (*), SUM (price) from the orders group by product;
Exercise: Find items that have purchased several categories of goods, and each category has a total price greater than 100
Select Product,sum (Price) from the orders group by product have sum (price) > 100;
* Summary SELECT statement: S-f-w-g-h-o combination Select ... from ... where ... a group by ....; Order by ...;
Order cannot be changed
The unique in MySQL