MySQL Learning Note (ii)

Source: Internet
Author: User

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)

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.