xml文件中的大/小于写法

本文解析了如何将SQL语句中的比较符号转换为XML写法,以适应特殊字符需求,并详细展示了两种转换方法,包括原符号替换和使用<![CDATA[]]>标签。重点在于课程成绩等级划分的SQL案例和其XML格式的实现。

1.原始sql:

select sc_grade,  case
					 when sc_grade >0   and sc_grade <60   then '不及格'
					 when sc_grade >=60 and sc_grade <=70  then '及格'
					 when sc_grade >70  and sc_grade <=80  then '良好'
					 when sc_grade >80  and sc_grade <=90  then '中等'
					 when sc_grade >90  and sc_grade <=100 then '优秀'
					 else '其他' end as grade_rank 
from t_student_course where sc_date='2019-06-06' and course_id='2'

2. xml中的写法

  1. 写法1:
    原符号 < <= > >= & ’ "
    替换符号 < <= > >= & ’ "
例:

select sc_grade, case
		when sc_grade &gt;= 0  and sc_grade &lt;  60 then '不及格'
		when sc_grade &gt;= 60 and sc_grade &lt;= 70 then '及格'
		when sc_grade &gt;= 70 and sc_grade &lt;= 80 then '良好'
		when sc_grade &gt;= 80 and sc_grade &lt;= 90 then '中等'
		when sc_grade &gt;= 90 and sc_grade &lt;= 100 then '优秀'
		else '其他' end as grade_rank 
from t_student_course where sc_date=#{sc_date} and course_id=#{course_id}

2.写法2:

 >= 的写法      <![CDATA[ >= ]]>

 <= 的写法      <![CDATA[ <= ]]>
例:

select sc_grade, case
	 when sc_grade <![CDATA[ >= ]]> 0 and sc_grade <![CDATA[ < ]]>   60 then '不及格'
	 when sc_grade <![CDATA[ >= ]]> 60 and sc_grade <![CDATA[ <= ]]> 70 then '及格'
	 when sc_grade <![CDATA[ > ]]>  70 and sc_grade <![CDATA[ <= ]]> 80 then '良好'
	 when sc_grade <![CDATA[ > ]]>  80 and sc_grade <![CDATA[ <= ]]> 90 then '中等'
	 when sc_grade <![CDATA[ > ]]>  90 and sc_grade <![CDATA[ <= ]]> 100 then '优秀'
	 else '其他' end as grade_rank 
from t_student_course where sc_date=#{sc_date} and course_id=#{course_id}
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值