有什么办法我可以合并查询与一个更多的名单教师身份证,如果列表空我查询只与时间,如果不是空我将合并与身份证在列表请有人能帮助我吗?
@Query(
value = "select i.start_time, i.end_time, i.duration_time, s.subject_class_name, u.name as teacher_name," +
" dc.name as class_room_name, ts.name as subject_name, tsc.total_time as total_time_subject_class," +
" i.teacher_context_type, i.teacher_id, s.subject_class_id" +
" from tbl_attendance_sheet as s inner join tbl_attendance_instance as i on s.id = i.attendance_sheet_id " +
" left join phong_hoc dc on i.class_id = dc.id " +
" left join lms_user u on u.id = i.teacher_user_id " +
" left join tbl_subject_class as tsc on tsc.id = s.subject_class_id " +
" left join tbl_subject as ts on ts.id = tsc.subject_id" +
" where " +
" ( " +
" ((:start_time >= i.start_time and :start_time <= i.end_time) " +
" or (i.start_time <= :end_time and :end_time <= i.end_time) or " +
" (:start_time < i.start_time and :end_time > i.end_time)) " +
" ) ",
nativeQuery = true
)
List<Tuple> getAllDetailTeacherCheckOn(
@Param("start_time") LocalDateTime startTime,
@Param("end_time") LocalDateTime endTime
);
字符串
我尝试使用(case when:teacher_ids is null then true else i.teacher_id in:teacher_ids end)“,但似乎不起作用。
1条答案
按热度按时间qoefvg9y1#
你需要做的是在查询中添加一个“AND”语句,检查列表中是否有匹配项,或者列表是否为空。看起来像这样:
第一个月