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!