Select city in Continent = 'Europe' with Max Population but without using Joins (MySQL)

440 Views Asked by At

I'm learning to write SQL queries in MySQL Workbench. At this moment I have two tables:

city table

enter image description here

country table

enter image description here

Is it possible to SELECT name of city With MAX population from city table which are in Continent of 'Europe', but without using Joins? (only using nested SELECT and Max() function)

Can't figure out how to work with two tables at the same time.

2

There are 2 best solutions below

0
Akina On

Schematically (adjust names):

SELECT city_name
FROM cities
WHERE 'Europe' = ( SELECT continent_name
                   FROM countries
                   WHERE cities.country_id = countries.id )
ORDER BY population DESC LIMIT 1
0
user15426703 On

SELECT Name FROM cities WHERE CountryCode IN ( SELECT Code FROM countries WHERE Continent = 'Europe') group by Name, countrycode having max(population)