直接上sql语句的写法:
sql语句的写法:
select * from table(table写自己的表名称)
where 1 = 1
and state = #{state,jdbcType = INTEGER}
and phone like concat ('%',#{number,jdbcType=VARCHAR})
order by XX(根据某个字段排序) desc
limit #{beginIndex,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}
其中parameterType = "hashmap" 表示通过map集合来传递参数,resultMap = "BaseResultMap"表示返回map形式的数据,如果不知道怎么通过map封装,可以参考我前两篇文章。
if 里面的state和number字段是封装到map集合中的key值,and 后面的state和phone是数据库的字段,phone表示电话号码
phone like concat ('%',#{number,jdbcType=VARCHAR}) 表示查询后四位和number相等的手机号,
而后面再加一个‘%’,phone like concat ('%',#{number,jdbcType=VARCHAR},'%')表示查询包含number的手机号