sql防止连表查询后出现空行数据
防止连表查询后出现空行数据
1.在where后加:and t2.pk_id is not null
或者2.在返回值list上处理
List TaskItem = intelligentCloudMapper.getTaskItem(params.getPkId());
TaskItem.removeAll(Collections.singleton(null));
<select id="getTaskItem" resultType="com.geofly.system.api.vo.TaskByFinishingBatchResultVo">
SELECT t2.pk_id as pkId, t2.create_by as createBy, t2.update_time as updateTime
FROM st_2k_image_s t1
LEFT JOIN st_2k_image_range_s t2 ON t1.pk_id = t2.fk_image_id
WHERE t1.pk_id = #{pkId} and t2.pk_id is not null
</select>