select dct.task_id , dct.device_id , dct.cmd , dct.create_time , dct.exec_time ,dct.result_time , dct.task_status ,dct.push_count
, dv.token , dv.unlock_token,dv.magic,dv.topic,dv.`status` as device_status,dv.cert_id,ci.p12_path,ci.p12_password,ci.cert_status from
device_command_task dct LEFT JOIN device_info dv on dct.device_id = dv.device_id LEFT JOIN cert_info ci on dv.cert_id = ci.cert_id where dv.device_id in (select device_id from device_info where status = "TokenUpdate")
select dct.task_id , dct.device_id , dct.cmd , dct.create_time , dct.exec_time ,dct.result_time , dct.task_status ,dct.push_count
, dv.token , dv.unlock_token,dv.magic,dv.topic,dv.`status` as device_status,dv.cert_id,ci.p12_path,ci.p12_password,ci.cert_status from
device_command_task dct LEFT JOIN device_info dv on dct.device_id = dv.device_id and dvstatus = "TokenUpdate" LEFT JOIN cert_info ci on dv.cert_id = ci.cert_id
select dct.task_id,
dct.device_id,
dct.cmd,
dct.create_time,
dct.exec_time,
dct.result_time,
dct.task_status,
dct.push_count,
dv.token,
dv.unlock_token,
dv.magic,
dv.topic,
dv. status as device_status,
dv.cert_id,
ci.p12_path,
ci.p12_password,
ci.cert_status
from device_command_task dct
inner JOIN device_info dv
on (dct.device_id = dv.device_id and dv.status = 'TokenUpdate')
LEFT JOIN cert_info ci
on dv.cert_id = ci.cert_id