PHP learning notes: MySQL database operations, learning notes mysql
Update statement
Update table name set field 1 = value 1, Field 2 = value 2 where Condition
Exercise:
Set the password of the person with the username '小' to 123456 @
Statement: UPDATE crm_user SET userpwd = '2017 @ 'where username LIKE '% ';
Effect
Group by and having: Group query having Group query Conditions
Syntax: select a, COUNT (B) from table group by a having count (B)> 2
MysqlBuilt-in statistical functions
Count (column name) Total
Sum (column name) summation
Avg (column name) Average
Max (column name) Maximum Value
Min (column name) Minimum value
Example:
1. Calculate the average number of classes
SELECT class, scores, AVG (scores) FROM jian_scores group by class;
2. Calculate the average score of the class, and the score must be higher than 70
SELECT class, scores, AVG (scores) FROM jian_scores group by class having avg (scores)> 70;