今天在写代码时,因为业务,需要在mybatis中,使用到大于号,小于号,所以就在SQL中直接使用了。 SELECT * FROM test WHERE 1 = 1 AND start_date = CURRENT_DATE AND end_date = CURRENT_DATE 可是,在执行时,总报错误: Error creating document instance.
今天在写代码时,因为业务,需要在mybatis中,使用到大于号,小于号,所以就在SQL中直接使用了。
SELECT * FROM test WHERE 1 = 1 AND start_date = CURRENT_DATE
可是,在执行时,总报错误:
Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 74; columnNumber: 17; 元素内容必须由格式正确的字符数据或标记组成。
把AND start_date >= CURRENT_DATE AND end_date
于是就想到了特殊符号,于是用了转义字符把>和
SELECT * FROM test WHERE 1 = 1 AND start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE
附:XML转义字符
< < 小于号
> > 大于号
& & 和
' ' 单引号
" " 双引号
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn