美文网首页
实现sql动态语句

实现sql动态语句

作者: alexanlder | 来源:发表于2017-12-11 21:29 被阅读0次

1.mapper多参数语句:

select * from table where age= #{age}

<if test="uname !=null and uname !=' ' ">  //判断非空

and uname like concat ( concat('%',#{uname}),'%') //like语句

</if>

2.foreach语句:

接口:public List<book> get(@Param("isbns") Set<String> isbns) throws Exception;

mapper语句:<select id="get" resultType="book">

select isbn, bname ,press from book where isbn in

<foreach item="isbn" index="index" collection="isbns" open="(" separator="," close=")">

#{isbn}

</>

3.语义冲突

//错误提示:The content of elements must consist of well-formed character data or markup. <= 是和等左边的符号冲突,需要用 进行转义

<![CDATA[ and buytime <= #{endDate} ]]>

相关文章

网友评论

      本文标题:实现sql动态语句

      本文链接:https://www.haomeiwen.com/subject/hluwixtx.html