SELECT
a.id projectId,
a.`code`,
a.`name`,
a.ext_string_value_26 priority,
a.ext_string_value_9 bearerDepartment,
a.create_time createTime,
a.ext_string_value_6 functionary,
a.`ext_string_value_35`,
e.kind,
e.version,
e.flow_id
FROM
(SELECT b.* FROM ( SELECT max( version ) AS version, technique_id FROM xx_project_technique_release_five WHERE del_flag = '0' AND efficient = '1' GROUP BY technique_id ) a
LEFT JOIN tm_project_technique_release_five b ON b.version = a.version
AND a.technique_id = b.technique_id
AND b.del_flag = '0'
AND b.efficient = '1'
) e
LEFT JOIN `xxx-project`.proj_elproject a ON e.technique_id = a.ext_string_value_35
LEFT JOIN xx_project_technique_release b ON e.flow_id = b.flow_id
LEFT JOIN `xxx-project`.proj_elprojectmember c ON c.object_id = a.id
LEFT JOIN `xxx-system`.sys_eluser d ON c.user_id = d.id
WHERE 1 = 1
and a.del_flag = '0'
AND c.role_key = 'PM'
AND c.is_key_member = '0'
//左链接动态获取一对多中 取多中距离当前时间最近的一条数据
LEFT JOIN tm_project_technique_release b ON end_time = ( SELECT MAX( end_time ) FROM tm_project_technique_release WHERE b.project_id = a.id )
标签:特定条件,technique,project,version,sql,JOIN,取多,id,LEFT
From: https://www.cnblogs.com/miyiyangdexin/p/17677395.html