<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.zjk.mapper.LearningPlanCourseMapper">
    <delete id="deleteByPlanId">
        delete from zjk_learning_plan_course where plan_id = #{id}
    </delete>


    <select id="geCourseNamesByPlanId" resultType="java.lang.String">

        SELECT
            STRING_AGG(course.course_name, ',') AS course_names
        FROM
            zjk_learning_plan plan
                LEFT JOIN
            zjk_learning_plan_course plan_course ON plan.ID = plan_course.plan_id
                LEFT JOIN
            zjk_learning_course course ON plan_course.course_id = course.id
        WHERE
            plan.ID = #{id}
        GROUP BY
            plan.ID, plan.plan_name;


    </select>
</mapper>
