• Register
1 vote
333 views

Problem :

I am very new to SQL Queries. Recently I have joined new team and I am given below task

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

I have written below query

SELECT country

FROM world

WHERE country LIKE '%u'

      and country LIKE '%a'

      and country LIKE '%o'

      and country LIKE '%i'

      and country LIKE '%e'

      and country NOT LIKE '% %'

But it is not giving expected answer which is "Mozambique"

I tried to do hard coding and it is like "where name like 'Moz' and it worked for me but can’t use it.

I have spent a lot of time in writing the correct query but still unable to do it. So I am looking for sql experts help in fixing my above query.

9 6 2
3,980 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

To fix your query you must try using and country LIKE '%a%' for your vowels requirement this will definitely search your entire string and not just a last letter.

Please find below your updated query:

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

 Above query will do the needful.  Hope it will save your lot of time.

5 4 2
17,150 points

Related questions

0 votes
1 answer 13 views
13 views
Problem: I need help in solving this problem: The internal connection pool has reached its maximum size and no connection is currently available!
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.7K views
1.7K views
Problem : I am using the Hibernate for a first time for my project and I am very new to Hibernate. I think I have followed all the instructions written in some tutorials but still I keep getting the below Exception that is in my title: Exception in thread "main" ... should just change a connection.pool_size property, but if I do so it guesses that I only will get more errors. Can anyone help me?
asked Jan 30, 2020 jwilliam 3.9k points
0 votes
1 answer 20 views
0 votes
2 answers 130 views
130 views
Problem : I have written the typical MyPersons table and I have also written the MyOrders table and it is defined in a particular way so that I can do the JOIN query like the below one to return the MyOrders for all of the MyPersons. SELECT MyPersons.LastName, ... my question is, how should I write the query that must return me all MyPersons with NO MyOrders? I must write this using Mysql.
asked Jan 27, 2020 jwilliam 3.9k points
0 votes
1 answer 222 views
222 views
Problem: I am little bit confused, which statement is true? In sql server, execute the sp_columns command to list all the columns in a table? True False
asked Feb 19, 2020 maddi86 5.4k points
0 votes
1 answer 15 views
15 views
Problem: How to get multiple counts with one SQL query? Thanks
asked Mar 9 ummesalma 27.2k points
0 votes
1 answer 22 views
0 votes
1 answer 34 views
0 votes
1 answer 28 views
28 views asked Oct 18, 2020 miki 1.9k points