1.in when the query condition is List
<SelectId="getmultimomentscommentscounts"Resulttype="int">SelectMoment_comment_count fromTbl_moment_commentcountwhereMidinch<foreachitem="Item"index="Index"collection="List"open="("Separator=","Close=")">#{item}</foreach> </Select>
.1 if the type of the parameter is list, then when used, the collection property must be specified as a list
- <select id= "findbyidsmap" resultmap="Baseresultmap">
- Select
- <include refid="base_column_list" />
- From Jria where ID in
- <foreach item="item" index="index" collection="list" open="(" Separator="," close=")">
- #{item}
- </foreach>
- </Select>
2.in when the query condition is an enumeration value
By default, using the Select XXX where in (xx,xx) query, the returned results are sorted by primary key, and if you want to sort the values in the In () order, you can do this: select * from Talbe where ID in (3,2,4,1) Order by FI Nd_in_set (ID, ' 3,2,4,1 ')
MyBatis SQL in query (MyBatis SQL statement passed in parameter is list) MyBatis in how to receive value when using in query