我希望数据库查询结果输出最近七天的记录(referral_users)

时间:2017-10-18 14:11:28

标签: mysql wordpress

get_results( "SELECT u.ID, 
            ( SELECT meta_value FROM " . $wpdb -> prefix . "usermeta WHERE meta_key = 'first_name' AND user_id = u.ID ) AS firstname, 
           ( SELECT meta_value FROM " . $wpdb -> prefix . "usermeta WHERE meta_key = 'last_name' AND user_id = u.ID ) AS lastname,
           ( SELECT COUNT( user_id ) FROM " . $wpdb -> prefix . "usermeta WHERE meta_key = 'user_parent' AND meta_value = u.ID ) AS referral_users 
              FROM
        " . $wpdb -> prefix . "users AS u 
              WHERE 
        ( SELECT COUNT( user_id ) FROM " . $wpdb -> prefix . "usermeta WHERE meta_key = 'user_parent' AND meta_value = u.ID ) > 0 
              ORDER BY referral_users DESC LIMIT 10 OFFSET 0" );

0 个答案:

没有答案