How display last_name from employees table contain 'a' or 'o' or 'e' letter?

Viewed 244

I want to display from the employees table, only rows where the last_name contains the letters a, o, or e. I wrote the query below but it doesn't work.

select last_name from Hr.employees where last_name like '%a,o,e';
2 Answers

As you are not closing your list with a percentage sign, your list will search only for names ending with the named letters.

Try this instead:

SELECT last_name
FROM Hr.employees
WHERE last_name LIKE '%a%' 
OR last_name LIKE '%o%'
OR last_name LIKE '%e%'

Read more on usage of LIKE operator here.

Try:

select last_name from Hr.employees 
where last_name like '%a%' or last_name like '%e%' or last_name like '%o%';
Related