Skip to main content

SQL IN operator in MyBatis

"student" table with two columns "id" and "name".
The following is an example query in XML file.

<select id="select" parametertype="HashMap" resulttype="String">
SELECT name FROM student WHERE id IN
<foreach item="item" index="index" collection="studentIds"
open="(" separator="," close=")">
#{item}
</foreach>
</select>

"studentIds" is the name of input list

Comments