Reputation: 281
MySQL Table video
id | path
4 | 89_1232
6 | 90_2121
I need to match path
before underscore _
. For instance 89
, 90
. Is it possible with MySQL query.
Right now what I am doing is, fetching all rows and then explode path
row:
"SELECT `path` FROM `video`
then foreach () { explode and check }
Upvotes: 1
Views: 41
Reputation: 9001
Example:
SELECT `path` FROM `video` WHERE `path` LIKE '89\_%' ESCAPE '\'
which will search for rows with the pattern 89_{anything}
, using the backslash \
as the escape character (to make sure the underscore _
is literal)
Upvotes: 3