问题描述
- SQL join 多表关联问题
- table:log_create_player
player_id uid created_time
1 11 121221
2 22 121212
table:log_login
player_id action_time
1 22323
1 33434
table:payment
pay_user_id pay_amount exchage
22 33 0.333想得到
player_id max(action_time) times doll
1 33434 2 9.999SQL语句:
DB::connection($this->db_name)->select(""select lcp.player_idlcp.player_namefrom_unixtime(created_time)from_unixtime(max(action_time))count(1) as times sum(o.pay_amount*o.exchange) from log_create_player lcp join log_login ll on lcp.player_id=ll.player_id left join{$this->db_payment}
.pay_order o on lcp.uid = o.pay_user_id where created_time between {$start_time} and {$end_time} and o.get_payment = 1 group by player_id having max(action_time)<{$interval}"");为什么最后的出来的是空????
解决方案
http://blog.csdn.net/dxnn520/article/details/8281467
解决方案二:
SQL学习笔记-join问题求解释.
时间: 2024-07-28 13:18:17