MISBoot快速开发平台

常用SQL语句

foreach元素属性介绍 :

item 表示集合中每一个元素进行迭代时的别名;

index 指定索引,用于表示在迭代过程中,每次迭代到的位置;

open 表示该语句以什么开始;

separator 表示在每次进行迭代之间以什么符号作为分隔符;

close 表示以什么结束 ;

插入
insert into sys_user(uuid, creator_id, creator, create_time, modifier_id, modifier, modify_time, creator_org_id,user_name,user_name_id,password,age,sex)

    values

    ( #{uuid}, #{creatorId}, #{creator}, #{createTime}, #{modifierId}, #{modifier}, #{modifyTime}, #{creatorOrgId},#{userName},#{userNameId},#{password},#{age},#{sex})
批量插入
insert into sys_user(uuid, creator_id, creator,create_time,modifier_id, modifier, modify_time,creator_org_id,user_name_id,user_name,password,age,sex)

    values
    <foreach collection="list" item="list" index="index" separator=",">

    (#{list.uuid},#{list.creatorId},#{list.creator},#{list.createTime},#{list.modifierId},#{list.modifier},#{list.modifyTime},#{list.userNameId},#{list.userName},#{list.password},#{list.age},#{list.sex})

    </foreach>
编辑
update sys_user set user_name = #{userName}  where user_name_id = #{user_name_id}
批量编辑
<foreach collection="list" item="list" index="index" open="" close="" separator=";">
    update   sys_user

     <set>

    user_name =#{list.userName}

    </set>
    where

    user_name_id = #{list.userNameId}

    </foreach>
删除
delete from sys_user where uuid = #{uuid}
批量删除
delete from  sys_user  where uuid in

    <foreach item="uuid" collection="array" open="(" separator="," close=")">

    #{uuid}
    </foreach>
查询
select  uuid, creator_id, creator,create_time,modifier_id, modifier, modify_time,creator_org_id,user_name_id,user_name,password,age,sex    from   sys_user
QQ在线咨询
客服 QQ
251122361
微信/手机
18973127736
办公电话
0731-89565588