<?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.yeejoin.amos.knowledgebase.face.orm.dao.TagMapper">

    <select id="queryTagByNameInPublishedDoc" parameterType="string" resultType="com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag">
        SELECT
          SEQUENCE_NBR sequenceNbr, REC_DATE recDate, REC_USER_ID recUserId, TAG_NAME tagName, TAG_CODE tagCode,
          TAG_TYPE tagType, TAG_STATUS tagStatus, TAG_REMARK tagRemark, CREATOR creator, AGENCY_CODE agencyCode
        FROM
          knowledge_tag
        WHERE
          SEQUENCE_NBR IN (
            SELECT DISTINCT TAG_SEQ FROM knowledge_tag_instance WHERE TARGET_SEQ IN (
              SELECT
                SEQUENCE_NBR
              FROM
                knowledge_doc_content
              WHERE DOC_STATUS = "PUBLISHED"))
          AND TAG_NAME LIKE CONCAT('%', #{tagName},'%')
    </select>
</mapper>
