INSERT INTO tqk_finance (id, add_time, price, `status`, backcash, uid, income, mark, phone, `client`, ids) SELECT null, DATE_FORMAT(NOW(),'%Y-%m-%d'), SUM(list.pub_share_pre_fee), 2, 0, 0, SUM(list.user_rate), list.tk_earning_time, list.relation_id, 'app', GROUP_CONCAT(id) FROM (SELECT id,relation_id,DATE_FORMAT(tk_earning_time, '%Y-%m') as tk_earning_time,tk_status,pub_share_pre_fee,alimama_share_fee,user_rate FROM `tqk_order_app` where `tk_status` = 3 and is_sync=0) list GROUP BY list.relation_id,list.tk_earning_time; UPDATE tqk_order_app SET is_sync=1 WHERE find_in_set(id, (SELECT GROUP_CONCAT(ids) FROM tqk_finance WHERE add_time=DATE_FORMAT(NOW(),'%Y-%m-%d') GROUP BY add_time)) and is_sync=0;
mysql更新group_concat语句。
select * from tab1 where find_in_set( id , select group_concat(ids) from tab2)
参考:https://blog.csdn.net/qq_30607881/article/details/78214312