Click here to Skip to main content
15,940,550 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am in 10th class and this can come in my boards, please help me, I wanna know that if I have to use 3 underscores in front of A?? And can I just use 4 underscores if in the question the A is in 5th place?

What I have tried:

Nothing as I don't have a PC or a Laptop
Posted
Updated 9-Mar-23 22:26pm

'_' is SQL for "match any single character", and "%" is SQL for "Match any number of characters" So for A as fourth letter:
SQL
SELECT * FROM Employees WHERE EmpName LIKE '___A%'
And for A in the fifth letter:
SQL
SELECT * FROM Employees WHERE EmpName LIKE '____A%'
 
Share this answer
 
as the underscore is '1' characters, the '%' is any length pattern.
where name like '___a%' // [ 4 '_' ]


"yes If 5 _ are needed, you can use them.
 
Share this answer
 
Just for completeness and to offer an alternative, depending on platform and version of SQL you are using, you could also use
SQL
where substring(name, 4,1) = 'A';
This would be my preference as it is immediately apparent which character I am querying
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900