<?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.schoolinout.api.mapper.ApiParentStudentRelationMapper">
    <insert id="insertOrUpdate">
        INSERT INTO tb_school_student_parent_relation (student_id, parent_id)
        VALUES (#{studentId}, #{parentId})
        ON DUPLICATE KEY UPDATE student_id = #{studentId},
                                parent_id  = #{parentId};
    </insert>
    <select id="selectOnlyOne" resultType="com.schoolinout.system.domain.ParentStudent">
        SELECT parent_id,
               student_id
        from tb_school_student_parent_relation
        where parent_id = #{parentId}
          and student_id = #{studentId}
    </select>
</mapper>