我真的很感兴趣,我最终用这个查询删除记录,包括
CREATE temporary TABLE IF NOT EXISTS temp AS
(SELECT colleges.college_name,
courses.course_name
FROM colleges
INNER JOIN courses
ON colleges.id = courses.college_id
WHERE colleges.college_name = 'College of Engineering'
AND courses.course_name = 'test'
GROUP BY colleges.college_name,
courses.course_name);
DELETE FROM temp
WHERE college_name = 'College of Engineering'
AND course_name = 'test';
DROP TABLE temp;
表学院拥有“工程学院”和“传播学院”的价值观,而表课程则具有两个价值“测试”。查询的结果是删除了测试值,而不是在工程学院进行测试。
答案 0 :(得分:2)
创建临时表的查询将过滤到colleges.COLLEGE_NAME = 'College of Engineering'
,因此它只包含具有该值的行。 DELETE
语句使用完全相同的过滤,因此它将删除临时表中的所有行。