MySQL Single table query

Source: Internet
Author: User
single-table query 1, query all:

SELECT * from table name;

2. Query the selected field data:

Select field name from table name;

3, query the data under the specified conditions:

Select field name from table name where condition (example id>3);

4, after the query for the field alias as:

Select formerly named as renamed from table name;

5, fuzzy query like:

Select *from table name where field name like one of the characters in the field (example ' small% ', then query out all the data in the field that begins with the fine print, '% percent sign stands for more than one ', ' _ Underline represents a ')

6. Sort ORDER BY:

SELECT * FROM table name order by field name; (Default ascending: ASC)

SELECT * FROM table name order by field name Desc; (Descending: DESC)

7. Limit the number of displayed data:

SELECT * FROM table name order BY field name limit 2;# Take two data in ascending field name, 2 limit two data

SELECT * FROM table name order BY field name limit 2, 2;

MySQL Single table query

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.