程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> sql-SQL join 多表關聯問題

sql-SQL join 多表關聯問題

編輯:編程綜合問答
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.999

SQL語句:
DB::connection($this->db_name)->select("select lcp.player_id,lcp.player_name,from_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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved