mysql 对 表里的 两个属性去重

时间:2022-08-19 03:42:15
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


mysql 对 表里的 两个属性去重





    // 对表的 两个属性去重
    
    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  
      



mysql 对 表里的 两个属性去重