SQL Query | Level – Basic 3

Question

Get all the employee detail from EmployeeDetail table
whose “FirstName” starts with A and contain 5 letters

in progress 0
Ritika Sohal 55 years 3 Answers 956 views Member 0

Answers ( 3 )

  1. select * from employee where lower(ename) like ‘a%’ and len(ename)=5;

  2. Since we know that FirstName will start from A so using like ‘%a’ is wrong/redundant. Also the total length of the FirstName is 5 letters , so rest of the 4 letters are _ (4 underscore). The underscore character ( _ ) represents a single character to match a pattern. More than one ( _ ) underscore characters can be used to match a pattern of multiple characters.

    select * from EmployeeDetail WHERE FirstName LIKE ‘A____’

  3. select * from employee
    where UPPER(first_name) like ‘A%’ and len(first_name)=5;

Leave an answer

Browse
Browse