Home > Backend Development > PHP Tutorial > 如何同时删除几个表?新手求指导

如何同时删除几个表?新手求指导

WBOY
Release: 2016-06-13 12:57:14
Original
1053 people have browsed it

怎么同时删除几个表?新手求指导
后台管理里根据ID删除一个表的相关的信息然后怎么删除其它几个表中相关ID的信息啊?急。。


------解决方案--------------------
既然有 id 就继续删嘛

或者高级点:用触发器
------解决方案--------------------
手册说:
通过在FOR EACH ROW之后使用BEGIN ... END复合语句结构,能够定义执行多条语句的触发程序。
------解决方案--------------------
DELIMITER $$
create trigger xi_delete after delete
   ON xinxi  for each row
FOR EACH ROW
BEGIN
   delete from us_xi  where userid=old.userid,
   delete from ccs_image where userid=old.userid,
   delete from guestbook where userid=old.userid,
   delete from friends where userid=old.userid;
END$$
DELIMITER;
------解决方案--------------------
老大都说了“既然有 id 就继续删嘛”。
联表删!
------解决方案--------------------
一般都是一个一个地删除。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template