当type == 1时,course_id关联的时t_course_info 这张表
当type == 2时,course_id关联的是t_venue_course_info这张表
所以现在,我在查询的时候,如何才能根据type来判断关联哪张表呢?而且查询的时候会对关联表的数据进行筛选。
求大家帮忙!
闭关修行中......
mysql has a case when, please explore it yourself
select * from course c left join t_course_info tci on tci.id = c.course_id and c.type = 1 left join t_venue_course_info tvci on tcvi.id = c.course_id and c.type = 2
Mybatis’ isEqual can implement this dynamic sql, but for these two businesses, wouldn’t it be better to just write two sql directly?
mysql has a case when, please explore it yourself
Mybatis’ isEqual can implement this dynamic sql, but for these two businesses, wouldn’t it be better to just write two sql directly?