Mysql for beginners (2)

Source: Internet
Author: User

Mysql for beginners (2)

Continue to update mysql for beginners today. The following are the necessary table search commands. Use table: student
1. query all the field data in the table: select * from student;

2. query the data of a field: select name from student;

3. query the data of multiple fields: select name, kemu, score from student;

4. query by condition (where): select * from student where scZ limit? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vcmUmZ3Q7ODA7PGJyIC8 + DQo8aW1nIGFsdD0 =" here write picture description "src =" http://www.bkjia.com/uploads/allimg/160403/04123SO2-3.png "title =" \ "/>
5. query by multiple conditions (where... And...): select * from student where kemu = 'pee' and score> 80;

6. For a student whose first letter is j, select * from student where name like 'J % ';

7. sort by student scores (ASC in ascending order and DESC in descending order): select * from student order by score asc;

8. query by keyword (in): select * from student where id in (1, 2, 3 );

9. query the score range (between and): select * from student where score between 80 and 90;

10. query data with no duplicate scores (distinct): select distinct name, score from student;

11. group 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. query using the common function count (). The benefit: If the query field is null, it will not be queried:
Select count (*) from student;

14. Use the common function sum () to calculate the sum: select sum (score) from student;

15. Use the common function avg () to calculate the average value: select avg (score) from student;

16. Use the common function min () to calculate the minimum value and max () to calculate the maximum value:
Select max (score), min (score) from student;

This is a temporary update today!

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.