1.无主外键级联删除,主表(tb_userinfo)用户表 
<!--删除用户那么与之用户相关联的所有信息都将被删除。根据用户的unionid删除所有相关数据 --> <delete
id="deleteUserinfoByid"> DELETE tb_userinfo, tb_attention, tb_building,
tb_code, tb_collection, tb_information, tb_recommend, tb_records, tb_forum FROM
tb_userinfo LEFT JOIN tb_attention ON (tb_userinfo.unionid =
tb_attention.unionids) LEFT JOIN tb_building ON (tb_userinfo.account =
tb_building.account) LEFT JOIN tb_code ON (tb_userinfo.unionid =
tb_code.unionid) LEFT JOIN tb_collection ON (tb_userinfo.unionid =
tb_collection.unionid OR tb_building.id = tb_collection.bid) LEFT JOIN
tb_information ON (tb_userinfo.unionid = tb_information.unionid) LEFT JOIN
tb_recommend ON (tb_userinfo.unionid = tb_recommend.unionid) LEFT JOIN
tb_records ON (tb_userinfo.unionid = tb_records.unionid) LEFT JOIN tb_forum ON
(tb_userinfo.unionid = tb_forum.unionid) WHERE tb_userinfo.unionid =
#{unionid}<!--条件,传入的参数 --> </delete>
2,无主外键级联更新,主表(tb_userinfo)用户表
UPDATE tb_userinfo u LEFT JOIN tb_borrow b ON (u.id = b.bid)<!-- 关联条件为用户ID
--> LEFT JOIN tb_borrow o ON (u.id = o.leid) LEFT JOIN tb_credit c ON (u.id =
c.userid) LEFT JOIN tb_friend f ON (u.id = f.bid) LEFT JOIN tb_receipt r ON
(u.id = r.userid) SET u.username = #{username},<!--用户名 --> b.borrower =
u.username, b.identitycard=u.identitycard, o.lender = u.username,
o.identitycards=u.identitycard, c.username=u.username, f.username=u.username,
r.username=u.username WHERE u.id = #{id}<!-- 根据用户id -->
 

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信