1.要去重的临时表:
SELECT
tpc.id courseId,tpc.name couresName
FROM ( SELECT * FROM ez_user_transaction_history euth WHERE euth.order_type = '3' ) uth
LEFT JOIN `ez_train_practical_course_user` tpcu ON tpcu.id = uth.order_id
LEFT JOIN `ez_train_practical_course` tpc ON tpcu.practical_course_id = tpc.id
LEFT JOIN `ez_user` u ON tpcu.user_id = u.id
// 对表的 两个属性去重
SELECT DISTINCT test.courseId ,couresName FROM
(
SELECT
tpc.id courseId,tpc.name couresName
FROM ( SELECT * FROM ez_user_transaction_history euth WHERE euth.order_type = '3' ) uth
LEFT JOIN `ez_train_practical_course_user` tpcu ON tpcu.id = uth.order_id
LEFT JOIN `ez_train_practical_course` tpc ON tpcu.practical_course_id = tpc.id
LEFT JOIN `ez_user` u ON tpcu.user_id = u.id
) test