Underscore is a wild card for single character search.
If your data contains an underscore ( _
), and want to use it as part of your like pattern, then escape it.
Example:
mysql> select * from (
-> select 1 rnum, 'Test_x_x_T1' t
-> union all
-> select 2, 'Test_x_xT1_'
-> union all
-> select 3, 'Test_x_xT1'
-> union all
-> select 4, 'Test_x_x_T1_'
-> ) tst
-> where t like '%\_T_';
+------+-------------+
| rnum | t |
+------+-------------+
| 1 | Test_x_x_T1 |
+------+-------------+
1 row in set (0.00 sec)