Skip to content
Advertisement

sql query : show name with all vowels

Equatorial Guinea and Dominican Republic have all of the vowels (a, e, i, o, u) in the name. They don’t count because they have more than one word in the name.

Find the country that has all the vowels and no spaces in its name?

You can use the phrase name NOT LIKE ‘%a%’ to exclude characters from your results. The query shown misses countries like Bahamas and Belarus because they contain at least one ‘a’

SELECT name
FROM world
WHERE name LIKE '%u' 
      and name LIKE '%a' 
      and name LIKE '%o' 
      and name LIKE '%i'
      and name LIKE '%e'
      and name NOT LIKE '% %'

it does not work. the right answer is “Mozambique”

i hard coded it like “where name like ‘Moz’. It worked , but it’s cheating

Advertisement

Answer

Try using and name LIKE '%a%' for your vowels, this will search the entire string and not just the last letter.

For example:

SELECT name
FROM world
WHERE name LIKE '%u%' 
  and name LIKE '%a%' 
  and name LIKE '%o%' 
  and name LIKE '%i%'
  and name LIKE '%e%'
  and name NOT LIKE '% %'
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement