求助大神,如何根据A表字段是否有值 对关联条件进行变更,如果A表字段1不是空值,匹配B表就进行字段1关联,字段2 字段3依次类推。
select * from A表 LEFT JOIN B表 ON A.日期=B.日期 AND CASE WHEN A.字段1 is not null then A.字段1=B.字段1 WHEN A.字段2 is null then " AND A.字段2=B.字段2" when A.字段3 is not null then " AND A.字段3=B.字段3"