The problem of arithmetic Operation of mybatis dynamic sql

the dynamic sql of mybatis is as follows in the xml file:


    count( DISTINCT item.RECORD_ID ) AS borrowNum -- ()
</if>

as above, I want to judge whether the eachBook field is 0 or 1 . May I ask how to write it? I didn"t say it even after reading the official mybatis document.

those who want to know will let me know, thank you.

Mar.28,2021

MyBatis is parsed using OGNL expressions, so to determine that a variable is equal to a certain value, use the following:

<if test='optionType == "1" '>

</if>

or

<if test="optionType == '1'.toString() ">

</if>

or

<if test="optionType == "1" ">

</if>

Why not use case when statement blocks


select sno,sname,age,saddress,
(case sex 
    when '0' then '' 
    when '1' then '' 
 else '' end) as  

from stud;
Menu