方法一:使用xml转义字符
如:
select phone, user_head, nickname, real_name, certificate_type, certificate_number, email, birthday_date,
(year(now())-year(birthday_date)-1) + (DATE_FORMAT(birthday_date, '%m%d') <= DATE_FORMAT(now(),'%m%d')) as age,heigth, weight, profession from yxs_user_info
where user_uuid = (select uuid from yxs_user_login_info from uuid2=#{uuid2})
select phone, user_head, nickname, real_name, certificate_type, certificate_number, email, birthday_date,<![CDATA[(year(now())-year(birthday_date)-1) + (DATE_FORMAT(birthday_date, '%m%d') <= DATE_FORMAT(now(),'%m%d')) as age]]>,heigth, weight, profession
from yxs_user_info where user_uuid = (select uuid from yxs_user_login_info from uuid2=#{uuid2})
附:XML转义字符
< | < | 小于号 |
> | > | 大于号 |
& | & | 和 |
' | ’ | 单引号 |
" | " | 双引号 |
方法二: 使用<![CDATA[运算内容]]>
因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用<![CDATA[ ]]>符号进行说明,将此类符号不进行解析。
select phone, user_head, nickname, real_name, certificate_type, certificate_number, email, birthday_date,<![CDATA[(year(now())-year(birthday_date)-1) + (DATE_FORMAT(birthday_date, '%m%d') <= DATE_FORMAT(now(),'%m%d')) as age]]>,heigth, weight, profession from yxs_user_info where user_uuid = (select uuid from yxs_user_login_info from uuid2=#{uuid2})