数据库实用技巧:AB表联合删除,从B表中删除no与A表中no相等且在A表记录sex字段为1的记录

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://hpzwl.blog.csdn.net/article/details/131077228

红胖子网络科技的博文大全:开发技术集合(包含Qt实用技术、树莓派、三维、OpenCV、OpenGL、ffmpeg、OSG、单片机、软硬结合等等)持续更新中…

数据库相关开发


需求

  数据库字段达到四五百个,在分表中,只有一个表存储了用户名字段,需要删除该用户名,于是需要在其他分表中删除该用户名的所有记录。


实现方式

  在这里插入图片描述

select * from student_info;
select * from student_info2;

delete from student_info2 
where no in (select no from student_info where sex = "1");
delete from student_info
where sex = "1";

select * from student_info;
select * from student_info2;

若该文为原创文章,转载请注明原文出处
本文章博客地址:https://hpzwl.blog.csdn.net/article/details/131077228

猜你喜欢

转载自blog.csdn.net/qq21497936/article/details/131077228
今日推荐