Reprint: http://www.cnblogs.com/best/p/6517755.html
1. Expressions and Conditional Queries
The WHERE keyword is used to specify the query condition, in the form of the Select Column name from the table name where condition;
To query all gender-based information as an example, enter a query statement: SELECT * from students where sex= "female";
The WHERE clause does not only support the "where Column name = value" Query form, which is named equal to the value, and is supported for the operators of general comparison operations such as =, >, <, >=, <,! =, and some extension operators are [not] null, in, and like Wait a minute. You can also combine queries with OR and and for query criteria, and later learn more advanced conditional query methods, which are no longer introduced.
Example:
Find information for everyone over the age of 21: SELECT * from students where ages > 21;
Query everyone with the word "King" in the name: SELECT * from students where name is like "% king";
Information for anyone with a query ID of less than 5 and older than 20: SELECT * from students where id<5 and age>20;
2. Aggregation Functions
total number of students received:SELECT COUNT (*) from students
average score for students:select AVG (Mark) from students
get the highest score:select Max (Mark) from students
get the lowest score:Select min (Mark) from students
get the student total:select SUM (Mark) from students
MySQL Learning Note (ii)