Mybatis中的mapper文件中不等于的几种写法
在XML文件中是不可以直接使用 < 、>、&的,语法检查会报错误。如需使用,需要将其转义为对应的实体。
预期执行SQL效果:select t.name form tablenme t where t.code <> 1;
第一种:转义
<
< (小于)>
> (大于)<>
<> (不等于)
mapper文件写法:
select t.name form tablenme t where t.code <>
1;
第二种:<![CDATA[]]>
<![CDATA[]]>
这个标记所包含的内容将表示为纯文本。
mapper文件写法:
select t.name form tablenme t where t.code <![CDATA[<>]]>
1;