下面这条sql怎么用动态sql拼接,主要是and和or那一块
SELECT *
FROM t LEFT JOIN l ON t.usernum = l.usernum AND t.date = l.date
WHERE
t.date = '2020-08-29'
-------------------------------------------
<if test=" age != '' and age != null ">
and t.age = #{age}
</if>
-------------------------------------------
AND (( t.math > 80 OR t.english > 80 )
OR ( t.pe > 90 OR t.politics > 90 )
OR t.status = '1'
OR t.class = '三班'
OR l.usernum >10)
-------------------------------------------
例如A不为空则执行t.math那段,B不为空则执行t.pe那段,C不为空则执行t.class那段,一直到结束...
<if test=" A != '' and A != null ">
t.math > 80 OR t.english > 80
</if>
<if test=" B != '' and B != null ">
t.pe > 90 OR t.politics > 90
</if>