MySQL LIKE query with underscore

前端 未结 1 726
天涯浪人
天涯浪人 2020-12-01 15:44

I have the following table images:

+----+--------------+
| id |   img_path   |
+----+--------------+
| 1  | abc_1.jpg    |
| 2  | abc_2.jpg    |         


        
相关标签:
1条回答
  • 2020-12-01 16:09

    Found out that _ is a special character. Have to escape with backslashes.

    SELECT id FROM images WHERE img_path LIKE 'abc\_%'
    

    which returns 2 rows as expected

    0 讨论(0)
提交回复
热议问题