刚开始用了一种错误的写法:<select id="findDataByMonitorplaceAndTime" resultType="org.hopeframework.db.model.Data" parameterType="org.hopeframework.db.model.Data"> select * from data where monitorplacename = #{monitorplacename,jdbcType=VARCHAR} and timedetail like %#{timedetail}% </select> 这种查询的写法会报错.改成如下那种就可以了:
<select id="findDataByMonitorplaceAndTime" resultType="org.hopeframework.db.model.Data" parameterType="org.hopeframework.db.model.Data"> select * from data where monitorplacename = #{monitorplacename,jdbcType=VARCHAR} and timedetail like concat(concat('%',#{timedetail},'%'))</select>
查询成功
mybatis中模糊查询的写法
最新推荐文章于 2024-08-10 16:15:08 发布