SQL Server Learning (2)

Source: Internet
Author: User

1.Top Query Statements

SELECT TOP n < column name table > from < table name > [Query condition]

Used to get the number of data bars returned by the rule.

SELECT TOP N PERCENT < list name > from < table name > [Query condition] Indicates the number of data bars for which the previous percentage was obtained.

2.LIKE operator

Query the records in the database by using a wildcard character.

_ Denotes matching with any single character

% indicates a match to a string containing one or more characters

[] matches any single character in a specific range (for example, [a-f]) or a specific set (for example, [abcdef]).

[^] or [!]  Matches any single character other than a specific range (for example, [^a-f]) or a specific set (for example, [^abcdef]).   

Escape identifier

For special characters appearing in strings: '% ', ' [', ' [] ', ' _ ' can use ' [] ' to include them, so that they are treated as ordinary characters.

Select 1 where ' aa_ssd ' like '%[_]% '

Use the characters immediately following the escape to make the escaped character. The character following the escape is equivalent to the escape character in the string ' \ '.

SELECT * from Test_course where name like '%\_% ' escape ' \ '

SQL Server Learning (2)

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.