SELECT user.user_id, user_name, PASSWORD, company, user.create_time, user.update_time ,COUNT(device.`device_id`) deviceCount FROM USER LEFT JOIN apply ON user.user_id = apply.user_id LEFT JOIN device ON apply.app_id = device.app_id
user.update_time,apply.app_id,
(SELECT COUNT(sn) FROM device WHERE apply.`app_id` = device.`app_id`) deviceCount
FROM USER LEFT JOIN apply ON user.user_id = apply.user_id