SELECT `a`.*, `b`.`id` as `attachment_id`, `b`.`attachment_name`, `b`.`location`, `b`.`file_type`, `b`.`file_ext`, `b`.`mask_id`, `c`.`action_efective_date`, `d`.`type` as `action_type`
FROM `user__license` `a`
LEFT JOIN `user__license_attachment` `b` ON `b`.`license_id` = `a`.`id` and `b`.`is_delete` = 0
LEFT JOIN `user__profiling` `c` ON `c`.`id` = `a`.`profiling_id`
LEFT JOIN `_ref__action_type` `d` ON `d`.`id` = `c`.`action_type_id`
WHERE `a`.`user_id` = '64'
AND a.profiling_id IN (SELECT MAX(a.profiling_id)
FROM `user__license` `a`
WHERE `a`.`user_id` = '64')
AND `a`.`is_delete` =0