SELECT
*
FROM
employees
WHERE
first_name LIKE 'A%'
OR first_name LIKE 'B%'
OR first_name LIKE 'C%'
OR first_name LIKE 'D%'
ORDER BY
first_name;
is there any new way to rewrite the SQL Query to find the first_name starting from A to P
Advertisement
Answer
Use regexp_like:
select * from employees where regexp_like(first_name, '^[a-p]', 'i')
The regex breakdown:
^means “start of text”[a-p]means “any character in the range à to p inclusive”- The
iflag means “ignore case”