R
R
rinaz222022-04-08 13:06:24
MySQL
rinaz22, 2022-04-08 13:06:24

Why does LIKE split _E into _ and E - mysql?

I'm doing a simple database search using LIKE.
`data` LIKE '%$val%'
$val contains e.g. _E
I get data from the database:
M_E
G_E
NEW_GO
ON_TEST
ONE_TEST
ON_EFDF
etc.
Those. c takes all records where there is E and _ Why doesn't it look for only _E?
Those. in theory it should be:
M_E
G_E
ON_EFDF

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Akina, 2022-04-08
@rinaz22

If all else fails, try reading the documentation.
LIKE operator

With LIKE you can use the following two wildcard characters in the pattern:
  • % matches any number of characters, even zero characters.
  • _ matches exactly one character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question