码迷,mamicode.com
首页 > 其他好文 > 详细

工作同时删除2张表中记录

时间:2017-08-10 16:59:28      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:style   blog   避免   .com   let   logs   enter   mysq   log   

技术分享

mysql:

delete a.*,b.* from sys_z_info a,sys_o_info b where a.z_id=b.d_id and a.z_id=‘123456‘

这个呢在只有1张表中有记录的时候不会起作用,不过可以考虑这样做:delete a.*,b.* from sys_z_info a,sys_o_info b where (a.z_id=b.d_id and a.z_id=‘123456‘ ) or  a.z_id=‘123456‘;这样就可以避免b中没有数据时不做删除操作了。

工作同时删除2张表中记录

标签:style   blog   避免   .com   let   logs   enter   mysq   log   

原文地址:http://www.cnblogs.com/tbb-pxq/p/7339720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!