Selecting records with underscore as second character in a column in MySQL using 'like'
mysql, select
Solution
Use:
Select * from books where title like '\_\_a%';
for two underscore at first and
Select * from books where title like '\_a%';
for single underscore at first and
Problem
I know for selecting the records with 'a' as the second letter in a column we write the following query:- ``` Select * from table where column1 like '_a%'; ``` For selecting the records with 'a' as the third letter in a column we write:- ``` Select * from table where column1 like '__a%'; ``` Now I want select the records where the `column1` contains '_'(underscore) as the second character.For example, I want to select the records with `column1` like A_John, B_John, A_Jai and so on. What is the escape character I can use in this case. How can I do that? Please help.