编辑
编辑
如图,sql语句在数据库里可以正常运行但是再XML文件不可以正常运行,报错。
原因:在XML中小于号"<"是会被默认认定成文一个标签的开始,所以用小于号就会报错。
解决办法:
1.把表达式反过来改成大于号
2.用<![CDATA[ ]]>包起来,就不会被认定成为标签
<![CDATA[
AND (stt.class_date + stt.class_start_time::interval < CURRENT_TIMESTAMP
OR (stt.class_date < CURRENT_DATE AND stt.class_start_time = '00:00:00'::time))
]]>
在这里我就展示一下用<![CDATA[ ]]>包起来的写法
SELECT
stt.id,stt.class_date,stt.class_start_time,stt.class_end_time,
(SELECT COUNT(*) FROM study_time_table_study_student sttss2 WHERE sttss2.study_time_table_id = stt.id AND sttss2.used_status = 1) AS actual_num,
-- stt.actual_num,
htm.teacher_name,htm.id as teacher_name_id,
tcm.class_name,tcm.class_type,tcoum.course_name,tcoum.id as course_name_id,stt.study_course_id,
sttss.study_student_id as student_id,ss.sts_student_name,ss.sts_phone
FROM study_time_table stt
JOIN
teach_class_manage tcm ON tcm.id = stt.study_class_id
JOIN
teach_course_manage tcoum ON tcoum.id = stt.study_course_id
JOIN
hr_teacher_manage htm ON htm.id = stt.hr_teacher_id
LEFT JOIN
study_time_table_study_student sttss ON stt.id = sttss.study_time_table_id
JOIN
study_student ss ON ss.id = sttss.study_student_id
where 1=1 AND stt.deleted = 0
AND sttss.used_status = 0
<![CDATA[
AND (stt.class_date + stt.class_start_time::interval < CURRENT_TIMESTAMP
OR (stt.class_date < CURRENT_DATE AND stt.class_start_time = '00:00:00'::time))
]]>
编辑