mysql - Same query without INNER JOIN? -


i'm trying convert query equivalent 1 no inner join.

select c.name, c.area, ai.sum_area     country c     inner join (         select sum(i.area) sum_area, gi.country                     island             inner join             geo_island gi on (i.name = gi.island)         group gi.country     ) ai on (c.code = ai.country) (c.area * 0.99) <= ai.sum_area; 

i'd learn how do, feel unconfortable statement, way find write queries.

edit: i'd appreciate instead of putting -1, tell me what's wrong question.

one option use "old" - non ansi sql compliant join syntax:

select c.name, c.area, ai.sum_area country c,       (         select sum(i.area) sum_area, gi.country          island i,          geo_island gi          (i.name = gi.island)          group gi.country ) ai  (c.area * 0.99) <= ai.sum_area   , c.code = ai.country; 

the other option use few subqueries (dependent , not-dependent) , in operator.

select * (     select c.name, c.area,             (                          select sum(i.area) sum_area                 island                  i.name in ( select island geo_island)                   , i.country = c.code             ) sum_area      country c  ) x  (area * 0.99) <= sum_area; 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -