Usage of MySQL Like statements

Source: Internet
Author: User

REGEXP
Example 1. the query field contains non-English data
Copy codeThe Code is as follows:
SELECT *
FROM'm _ user'
WHERE 'emp_no'
REGEXP '[^-~] '= 1
 
Column 2. In this way, all non-English content can be obtained.
Copy codeThe Code is as follows:
SELECT *
FROM table
WHERE name
Not regexp '[a-zA-Z0-9] +'

In addition to regexp, you can also use FIND_IN_SET and like to perform operations.
FIND_IN_SET
In mysql, how to use FIND_IN_SET (), and note the use of FIND_IN_SET (), as well as the differences between the use of IND_IN_SET () and in () in the second world.
Query the table field pingid = (1, 2, 3,) in mysql ,)
Copy codeThe Code is as follows:
SELECT * FROM 'linkinfo 'where 'pingid' REGEXP '{id},' AND 'pingid' not regexp '[[: alnum:] + {id },'

The preceding statement can be used for query.

Like
In MySQL, the SQL mode is case-insensitive by default. Some examples are shown below. Note that when you use SQL mode, you cannot use = or! =; And use the LIKE or not like comparison operator.
SELECT field FROM table WHERE a field Like Condition
SQL provides four matching modes for conditions:
1, %: represents any or multiple characters. It can match characters of any type and length.
For example
Copy codeThe Code is as follows:
SELECT * FROM [user] WHERE u_name LIKE '% 3%'

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.