$num = M('joinactivity as a')->join('fh_activity as b on b.a_id = a.a_id')->where($where)->count();
echo M('joinactivity as a')->_sql();
SELECT COUNT(*) AS tp_count FROM fh_joinactivity as a INNER JOIN fh_activity as b on b.a_id = a.a_id WHERE a.u_id = 1 AND a.is_read = 0 AND b.a_time < 1486556237 LIMIT 1