1. 程式人生 > >一張表中不同行的資料(join聯合)查詢到同一條資料中

一張表中不同行的資料(join聯合)查詢到同一條資料中

$list = Db::query('select t.phone_number,t.group_name,t1.friend_number F1,t2.friend_number F2,(t2.friend_number-t1.friend_number) f from gd_wxcount t
            join(select phone_number,friend_number from gd_wxcount where date_at="2018-09-15" and phone_number="B34") t1 on t1.phone_number=t.phone_number
            join(select phone_number,friend_number from gd_wxcount where date_at="2018-09-16" and phone_number="B34") t2 on t2.phone_number=t.phone_number
            group by phone_number
            ');