Nesting queries in SQL

前端 未结 4 845
余生分开走
余生分开走 2020-12-28 20:11

The goal of my query is to return the country name and its head of state if it\'s headofstate has a name starting with A, and the capital of the country has greater than 100

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-28 20:39

    You need to join the two tables and then filter the result in where clause:

    SELECT country.name as country, country.headofstate 
    from country
    inner join city on city.id = country.capital
    where city.population > 100000
    and country.headofstate like 'A%'
    

提交回复
热议问题