本文介绍了单个查询的多个删除语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定两个表,photos
和 keywords
,其中 photos.ID = keyword.photos
,如何从两个表中删除相同的行单个查询中的表?photos
表只有一条记录,而 keywords
有 9 个对 photos
记录的引用.
Given two tables, photos
and keywords
, where photos.ID = keywords.photos
, how can I delete the same rows from both tables in a single query? The photos
table has a single record, while keywords
has 9 references to the photos
record.
我试过了
DELETE FROM photos
INNER JOIN keywords ON photos.ID = keywords.photo
WHERE photos.ID = 262;
我收到错误 1064,指出从 INNER JOIN 关键字
开始并在语句的其余部分继续存在错误.
I get a Error 1064 stating an error exists starting at INNER JOIN keywords
and continuing for the rest of the statement.
但是,当我通过
SELECT * FROM photos
INNER JOIN keywords ON photos.ID = keywords.photo
WHERE photos.ID = 262;
,我得到一组 9 行返回.
, I get a set of 9 rows returned.
推荐答案
需要添加要删除的表名
DELETE photos
FROM photos
INNER JOIN keywords ON photos.ID = keywords.photo
WHERE photos.ID = 262;
这篇关于单个查询的多个删除语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!