WHERE IN手順


通常、WHERE IN構文を書くとINの順に行が入力されません
PRIMARY KEY順で行を入力
ORDER BY FIELDセクションを追加して順番にインポート
ORDER BY FIELD (KEY, VAL1, VAL2, VAL3)
私が使っている方法
<select id="selectInfoList" parameterType="String" resultMap="InfoBean">
     	SELECT 
			A.a, B.b
		FROM 
			TABLE1 A, TABLE2 B
		WHERE 
			A.a = B.b
			AND B.b IN (
			<foreach collection="array" item="id" index="i" separator=",">
				#{id}
			</foreach>
			)
			<if test="id != null and id != ''">
				ORDER BY (
					A.a,
						<foreach collection="array" item="id" index="i" separator=",">
							#{id}
						</foreach>
				)
			</if>	
</select>