SQL wildcard small problem online emergency

Source: Internet
Author: User
I MySQL rookie a
Problems encountered with wildcards help you, big God.

I want to select the data in the users table with the name "Szo" or "Szö"
So write the following code:
SELECT * from the users where name like '%sz[oö]% '

The database has such data
But the return value is 0.
Try
SELECT * from the users where name like '%szo% ' or the name like '%szö% '

With results
May I ask what is different between the two?


Reply to discussion (solution)

MySQL like wildcard characters are only "_" and "%"
"_" is a match for any single character
"%" is a match for any number of characters.

SELECT * from the users where name like '%sz[oö]% '
The name contains a record of sz[oö].
Instead of records that contain Szo or szö

Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp

Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

MySQL like wildcard characters are only "_" and "%"
"_" is a match for any single character
"%" is a match for any number of characters.

SELECT * from the users where name like '%sz[oö]% '
The name contains a record of sz[oö].
Instead of records that contain Szo or szö
Got a solution?

SELECT * from the users where name like '%szo% ' or the name like '%szö% '
Haven't you already solved it with this method?


Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

No way? How did you write the regexp?
SELECT * from users where name RegExp ' Sz[oö] '

SELECT * from  userswhere  nameregexp  ' (A-Z) *sz (O|ö) (A-Z) * ' LIMIT 0, 30

Okay, thanks, everybody.
Knot posts



Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

No way? How did you write the regexp?
SELECT * from users where name RegExp ' Sz[oö] '
Because like does not recognize [oö],regexp does not recognize%, so pull

SELECT * from  userswhere  nameregexp  ' (A-Z) *sz (O|ö) (A-Z) * ' LIMIT 0, 30

SELECT * from the users where name like '%szo% ' or the name like '%szoö% '



Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

No way? How did you write the regexp?
SELECT * from users where name RegExp ' Sz[oö] '
Try your code more than my simple and useful
Thank you for not being my rookie. Patient answer




Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

No way? How did you write the regexp?
SELECT * from users where name RegExp ' Sz[oö] '
Because like does not recognize [oö],regexp does not recognize%, so pull

SELECT * from  userswhere  nameregexp  ' (A-Z) *sz (O|ö) (A-Z) * ' LIMIT 0, 30


Now that you've used regexp, what's the use of%? This is like wearing hiking shoes to play basketball?

SELECT * from the users where name like '%szo% ' or the name like '%szö% '
Haven't you already solved it with this method?
It's a long story, and it's aäiïuü trouble.




Like is not a regular expression match. Instead of matching wildcard characters% and _, this is not supported for [XY] groups.
You can try RegExp
Tried, the same result
Is there any other way?

No way? How did you write the regexp?
SELECT * from users where name RegExp ' Sz[oö] '
Try your code more than my simple and useful
Thank you for not being my rookie. Patient answer

It's polite. Who didn't come from the rookie.
Mastering certain skills can often double the efficiency of learning.

  • 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.