Reputation: 4272
SELECT *
FROM list
WHERE list_item LIKE "%_1375_%"
returns results it should not. For example a result with 13753 in the list_item instead of 1375, even though the 3 comes before the underscore.
_13753_ and _1375_ are written above and not suppose to be italic.
Is there anyway to fix that?
Upvotes: 0
Views: 73
Reputation: 6120
From MySQL reference manual here
SQL pattern matching enables you to use “_” to match any single character and “%” to match an arbitrary number of characters (including zero characters).
So, you'll have to escape them to match a literal underscore character. Like so:
SELECT * FROM list
WHERE list_item LIKE "%\_1375\_%"
Upvotes: 2
Reputation: 134941
Underscore means any character. Are you looking for values with an underscore? In that case you need to escape it
SELECT *
FROM list
WHERE list_item LIKE "%\_1375\_%"
Upvotes: 1