How to filter the row which contains all vowels in the column value.
for example, the table letters contains list of column value.
str
----
apple
orange
education
I tried the sql with like command.
select str from letters
where
str like '%a%'
and str like '%e%'
and str like '%i%'
and str like '%o%'
and str like '%u%'
Would like to know is there any better way to handle this?
Expected output is : education
2
Answers
You can use
ilike all()
to make that shorterYou can use arrays for that
the build in array function
@>
means contains, which does exactly what you want, so all values from theARRAY['a','e','i','o','u']
must be in the arrayregexp_split_to_array(str, 's*')
manual array functions
a_horse_with_no_name write in the comments
so i added it to the answer
fiddle