I have started to learn MySQL.
Here is the table world
:
+-------------+-----------+---------+
| name | continent | area |
+--
If it's an Exercise from SQLZoo, than IMO it should look something like this:
select continent, name from world x
where name = (select name
from world y
where x.continent = y.continent
order by name asc
limit 1)
P.S. I study SQL from there now and this post helped me. Thanks to @Parado!)
Update: I've found this site with answers. Useful if stack.
SELECT continent,
name
FROM world x
WHERE name=
(SELECT name
FROM world y
WHERE x.continent=y.continent
ORDER BY name
LIMIT 1)
This is correlated/ synchronous query.
Try this
select distinct w.continent,
(select w2.name
from world w2
where w.continent = w2.continent
order by name asc
limit 1) name
from world w
order by w.continent
Try this
SELECT continent, name FROM world ORDER BY name ASC;
SELECT distinct x.continent , x.name
FROM world x ,world y
WHERE x.name = (SELECT y.name FROM world y
WHERE y.continent=x.continent order by y.name asc limit 1 ) ;
select continent, name from world group by continent order by name