SQL Search Statements and filter statements

Source: Internet
Author: User

First of all, recommend a more useful database management software: Navicat Premium.

    • The most important retrieval function in a database: SELECT statement

1. Retrieve a single column: Select Column name from table name;

2. Retrieve multiple columns: Select Column Name 1, column name 2,...from table name;

3. Retrieve all Columns: SELECT * from table name;

4. Retrieve different rows: Select DISTINCT column name from table name; */* Column with duplicate values, show only different values

5. Search Limit number of rows: Select Column name from table name limit quantity;/* Returns data with no more than a few rows

6. Retrieves the specified number of rows: Select Column name from table name limit (m,n);/* returns n rows beginning with line m

7. Use fully qualified table name: Select Table name. column name from database. Table name;

    • Sort statement: ORDER BY statement

1, order BY column name 1, column name 2;

2. Order BY column name Dec; descending order

    • Filter statement: where statement

1. WHERE clause operator:

Column name =; column name <>; column name <; column name >; Column name >=; column name <=; column name between and; column name is null;

2. Combine WHERE clause:

①and operator: Select column Name 1, column name 2, column name 3 from table name where column name 1= and column Name 2 =;

②or operator:

③in Operator: Specifies the condition range, where column name in (M,n,... );

④not operator: Specified range, not in (M,n,...);

3, the use of like+ wildcard filter: Wildcard characters used to match the value of a part of the special character, wildcard characters need to use single quotation marks.

①%: Any number of occurrences of any character;

②% character%: Identifies a value that matches any position that contains a character;

③x%y: Indicates that there is more data with the beginning of x ending with y;

④ underline: matches a single character;

4. Regular expressions

SQL Search Statements and filter statements

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.