'Matching field + "Ctiy"
How would you solve this problem:
You have a table with country names and capitals like this:
tk, name, capital
How would you SELECT name where countries equals capital + "City". So you would get results like Mexico City and Panama City etc?
This question come from the following problem: "The capital of Mexico is Mexico City. Show all the countries where the capital has the country together with the word "City".
Find the country where the capital is the country plus "City"."
Solution 1:[1]
You can concatenate the country's name to ' City' then compare it to its capital in the where clause:
select name
from countries
where capital = name || ' City';
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
