PHP learning notes: MySQL database operations, learning notes mysql

Source: Internet
Author: User

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;

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.