MySQL Basic Operation-sql Query statement

Source: Internet
Author: User

1. Querying data

Select Property List

From table name and view list

[Where Condition expression 1]

[Group By property name 1 [having conditional expression 2] [with rollup the last record is the sum of the above Records]]//The field specified by the attribute name 1 is grouped, there is having to satisfy the conditional expression 2

[Order BY property name 2 [Asc|desc]]

where query condition:

Compare =, <, <=, >, >=,! =, <>,!>,!<

Specify the range between and, not between and

Specifies the collection in, not in

Match characters like, don't like <%: represents any length string, _: Represents a single character >

Null value is NULL, is not NULL

Eg:select * from test0 where ID in (1001,1004,1005);

SELECT * from test0 where ID between 1002 and 1005;

SELECT * FROM test0 where ID < 1004 and name like ' H_h_ '; Two conditions are met

SELECT * FROM test0 where ID < 1004 or name like ' h% '; Meet one of them to

Select distinct name from Test0; Query results are not duplicated

Select Id,group_concat (name) from the Test0 group by name;//displays the specified field values in the name group

Select Name,count (name) from the TEST0 group by name;//counts the number of records in each group of name groupings

Select Name,count (name) from TEST0 group by name has count (name) > 1; Shows the number of records greater than 1

A having expression is a record that acts on a group, and where acts on a table or view.

Select Name,count (name) from TEST0 group by name with rollup;

SELECT * from Test0 limit 3; Show only 3 records

SELECT * from Test0 limit 1, 3; Showing 3 records from 2nd record

MySQL Basic Operation-sql Query statement

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.