从MySQL中的多个表中删除行 [英] Deleting rows from multiple tables in MySQL

查看:78
本文介绍了从MySQL中的多个表中删除行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我想要做的:

projects表中删除一个项目,并在images表中删除与该项目关联的所有图像.

Delete a project from the projects table and all the images associated with that project in the images table.

让我们说$del_id = 10

DELETE FROM projects, images WHERE projects.p_id = '$del_id' AND images.p_id = '$del_id'

此查询出了什么问题?

推荐答案

DELETE projects, images 
FROM projects, images 
WHERE projects.p_id = '$del_id' 
AND projects.p_id = images.p_id;

这篇关于从MySQL中的多个表中删除行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆