How can I find the countries where the capital name includes the name of the country.
ex:
Country Capital
--------------------
A Acity
B B
C xxx
D capital of D
The answer would return A,B and D
I have tried this, but is only returning country B
SELECT name, capital
FROM world
WHERE name LIKE capital
This question is the thirteenth question from Sqlzoo
You need to use it's correct concatenation syntax.
SELECT name, capital
FROM world
WHERE capital LIKE concat('%',name,'%')
Note the below query is correct for most DBMS
SELECT name, capital
FROM world
WHERE name LIKE '%' + capital + '%'
But ill raise an error at Sqlzoo
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '+ capital + '%'' at line 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With