mysql多表删除实例-创新互联
mysql多表删除
成都创新互联是一家专注网站建设、网络营销策划、微信小程序开发、电子商务建设、网络推广、移动互联开发、研究、服务为一体的技术型公司。公司成立十载以来,已经为近千家轻质隔墙板各业的企业公司提供互联网服务。现在,服务的近千家客户与我们一路同行,见证我们的成长;未来,我们一起分享成功的喜悦。删除某学生基本信息的同时,删除该学生的所有成绩
mysql> select * from stu_inf; +----+----------+--------+-------+-------+--------+ | id | stu_xh | stu_xm | xb_id | xy_id | stu_bj | +----+----------+--------+-------+-------+--------+ | 1 | 07150101 | 小明 | 1 | 1 | 1504 | | 2 | 07150240 | 谢育政 | 1 | 2 | 1502 | | 3 | 12341231 | 猴子 | 1 | 2 | 1515 | | 4 | 01591261 | 大大 | 1 | 3 | 1515 | | 5 | 07160202 | 小红 | 2 | 4 | 1602 | | 6 | 07150225 | 黄河 | 1 | 3 | 1315 | | 7 | 01050001 | 华容 | 1 | 7 | 1612 | | 8 | 02050002 | 黄月英 | 2 | 8 | 1608 | | 9 | 01510003 | 欢欢 | 2 | 9 | 1601 | | 10 | 05261005 | 大康 | 1 | 10 | 1304 | | 13 | 0001 | xxx | 1 | 2 | 1555 | +----+----------+--------+-------+-------+--------+ 11 rows in set (0.02 sec) mysql> select * from cj_inf; +-------+----------+---------+----------+ | cj_id | cj_stuid | cj_kmid | cj_score | +-------+----------+---------+----------+ | 1 | 3 | 1 | 87 | | 2 | 1 | 2 | 65 | | 3 | 4 | 1 | 77 | | 5 | 3 | 9 | 76 | | 7 | 1 | 1 | 90 | | 15 | 13 | 9 | 90 | | 16 | 13 | 8 | 67 | | 13 | 13 | 1 | 88 | +-------+----------+---------+----------+ 8 rows in set (0.02 sec)删除语句:
mysql> DELETE stu_inf,cj_inf from stu_inf LEFT JOIN cj_inf ON stu_inf.id=cj_inf.cj_stuid WHERE stu_inf.id=13; Query OK, 4 rows affected (0.00 sec)执行语句后:
mysql> select * from stu_inf; +----+----------+--------+-------+-------+--------+ | id | stu_xh | stu_xm | xb_id | xy_id | stu_bj | +----+----------+--------+-------+-------+--------+ | 1 | 07150101 | 小明 | 1 | 1 | 1504 | | 2 | 07150240 | 谢育政 | 1 | 2 | 1502 | | 3 | 12341231 | 猴子 | 1 | 2 | 1515 | | 4 | 01591261 | 大大 | 1 | 3 | 1515 | | 5 | 07160202 | 小红 | 2 | 4 | 1602 | | 6 | 07150225 | 黄河 | 1 | 3 | 1315 | | 7 | 01050001 | 华容 | 1 | 7 | 1612 | | 8 | 02050002 | 黄月英 | 2 | 8 | 1608 | | 9 | 01510003 | 欢欢 | 2 | 9 | 1601 | | 10 | 05261005 | 大康 | 1 | 10 | 1304 | +----+----------+--------+-------+-------+--------+ 10 rows in set (0.00 sec) mysql> select * from cj_inf; +-------+----------+---------+----------+ | cj_id | cj_stuid | cj_kmid | cj_score | +-------+----------+---------+----------+ | 1 | 3 | 1 | 87 | | 2 | 1 | 2 | 65 | | 3 | 4 | 1 | 77 | | 5 | 3 | 9 | 76 | | 7 | 1 | 1 | 90 | +-------+----------+---------+----------+ 5 rows in set (0.02 sec)另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
标题名称:mysql多表删除实例-创新互联
分享URL:http://azwzsj.com/article/dgship.html