conditions

< select > <when test="isUpload"> </when> </otherwise> </otherwise> </ select > Then choose ends. SQL in otherwise is executed when the condition for all WHEN in CHOOSE is not satisfied. Similar to the Java switch statement, choose is switch, when is case, otherwise is default. > <if> <if test="id "; = null ">id=#{id}</if> <if test="name! = null and name.length()>0 0" >and name=#{name}</if> <if test="gender! = null and gender.length()>0">and gender = #{gender}</if> </where>

function

The IFNULL() function determines if the first expression is NULL, and returns the value of the second argument if it is NULL, or the first argument if it is not NULL.

More than to

<trim prefix="" suffix="" suffixOverrides="" prefixOverrides=""></trim> prefix: prefix SQL statement in trim tag. Suffix: Add the suffix to the SQL statement in the trim tag. SuffixOverrides: Specifies that suffixOverrides=",","," remove unnecessary suffixOverrides from trim tags.

A collection of

In with <foreach> passes multiple parameters item: a required alias for the iteration of an element in the collection. Index: In lists and arrays,index is the number of the element, and in maps,index is the key of the element. Optionally, this is the opening symbol of the foreach code, usually used with (close=")". Commonly used in(),values(). Separator: The separator between elements. For example, in(), separator="," automatically separates the elements with "," to avoid SQL errors caused by manually entering commas, such as in(1,2,). This parameter is optional. Close: The closing symbol of the foreach code, usually) and open="(". Commonly used in(),values(). This parameter is optional. Collection: To make foreach objects, List objects have "List" as the default key. Array objects have "array" as the default key. Map objects have no default key. Of course, you can use @param ("keyName") to set the key as an input parameter. If you set the keyName, list and array will be invalidated. In addition to the case of input, there is also the case of a field of a parameter object. For example: if User has attributes List ids. If the input parameter is a User object, then the collection = "ids". If User has attribute Ids Ids; Where Ids is an object, and Ids has a property, List id; If the input parameter is a User object, then collection = "ids.id"

Get a key value

Add usegeneratedKeys ="true" keyProperty="id" in the Mapper file. So here's the ID that we got