<?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="com.hxhq.business.mapper.StudySubjectUserMapper">
    <select id="getHasFormNameList" resultType="java.lang.String">
        SELECT GROUP_CONCAT(DISTINCT user_mc SEPARATOR '、') FROM
        (
        SELECT DISTINCT user_mc
        FROM `t_study_form_fill` WHERE del_flag='0' AND study_id=#{studyId} AND user_id IN
        <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
            #{userId}
        </foreach>

        UNION ALL

        SELECT DISTINCT user_mc
        FROM `t_study_form_pre` WHERE del_flag='0' AND study_id=#{studyId} AND user_id IN
        <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
            #{userId}
        </foreach>

        UNION ALL

        SELECT DISTINCT user_mc
        FROM `t_study_form_plan` WHERE del_flag='0' AND study_id=#{studyId} AND user_id IN
        <foreach collection="userIdList" item="userId" open="(" separator="," close=")">
            #{userId}
        </foreach>
        )a
    </select>
</mapper>