11lxm 发表于 2016-11-20 08:40:09

postgresql联合查询、连接查询


[*]联合查询

select* from cw.cities c,(select state, MAX(pop) maxFROM cw.citiesgroup by state) twhere t.state = c.state and t.max=c.pop

 
 

selectc.* from cw.cities c,(select state, MAX(pop) maxFROM cw.citiesgroup by state) twhere t.state = c.state and t.max=c.pop
 
 
 


[*]left join on and

selectc.* from cw.cities c left join (select state, MAX(pop) maxFROM cw.citiesgroup by state) ton t.state = c.state and t.max=c.pop
  
 
 


[*]left join on where

 

selectc.* from cw.cities c left join (select state, MAX(pop) maxFROM cw.citiesgroup by state) ton t.state = c.state where t.max=c.pop
  
 
 


[*]inner join on and

 

selectc.* from cw.cities c inner join (select state, MAX(pop) maxFROM cw.citiesgroup by state) ton t.state = c.state and t.max=c.pop
  
页: [1]
查看完整版本: postgresql联合查询、连接查询