Click here to Skip to main content
15,745,973 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Ihave a table named tbl_emp which contains (firstname,lastname,birthdate,civilstatus,religion). How can I get all the employees whose first name starts with letter R without using LIKE 'R%' and substring. Is there another way?

What I have tried:

SELECT firstname
FROM tbl_emp
WHERE firstname LIKE '5%'

and the other one uses substring.
Posted
Updated 3-Jul-17 2:51am

1 solution

It's really the same solution as the SUBSTRING, but you could use LEFT (Transact-SQL) | Microsoft Docs[^]
And your LIKE is wrong: LIKE 'R%' not LIKE '5%' (but you just mistyped, I suspect).
 
Share this answer
 
Comments
Member 13288726 3-Jul-17 9:19am    
sorry for that typo and Thank you for your response. very helpful :)
OriginalGriff 3-Jul-17 9:26am    
You're welcome!

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