Beginner MySQL Summary (2)

Source: Internet
Author: User

Continue to update the beginner MySQL today, and the following are the commands for the required lookup table. Usage Table: Student
1, Query table All field data: SELECT * from student;

2. Query data for a field: select name from student;

3. Querying data for multiple fields: select Name, Kemu,score from student;

4, based on criteria query (WHERE): SELECT * FROM student where score>80;

5. Query based on multiple criteria (where ... and.): SELECT * from student where kemu= ' PE ' and score>80;

6, according to the name of the first letter of the student query: SELECT * FROM student where name like ' j% ';

7, sorted by student score (ascending ASC, descending desc) query (ORDER BY): SELECT * FROM student order by score ASC;

8, according to the keyword (in) query: SELECT * FROM student where ID in (A/n);

9, the interval of the query score (between and): SELECT * from student where score between and 90;

10, query score non-duplicated data (DISTINCT): SELECT distinct name, score from student;

11, packet query (group BY): SELECT * FROM student group by name;

12, limit the number of query results (LIMIT): SELECT * FROM Student ORDER by ASC limit 5;

13, using the common function count () query, the benefit: If the query field is NULL, it will not be queried:
Select COUNT (*) from student;

14, use the common function sum () To sum: select SUM (score) from student;

15, using the usual function avg () Averaging: Select AVG (score) from student;

16, use the usual function min () to find the minimum value, max () to find the maximum value:
Select Max (Score), Min (score) from student;

Today, temporarily updated to here!

Beginner MySQL Summary (2)

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.