多表join使用说明
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on a.userId=c.userId
等价于
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on b.userId=c.userId
等价于
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on a.userId=c.userId and b.userId=c.userId
总结:
可以把a与b表join关联看成一个新的表table_j,table_j表有两列a.userId,b.userId与c表进行关联
如果是l
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on a.userId=c.userId
等价于
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on b.userId=c.userId
等价于
select * from (select userId from table_a where dt=20160731) a join (select userId from table_b where dt=20160731) b on a.userId=b.userId join (select userId from table_c where dt=20160731) c on a.userId=c.userId and b.userId=c.userId
总结:
可以把a与b表join关联看成一个新的表table_j,table_j表有两列a.userId,b.userId与c表进行关联
如果是l