Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何删除查询中未指定的所有记录_Mysql_Sql - Fatal编程技术网

Mysql 如何删除查询中未指定的所有记录

Mysql 如何删除查询中未指定的所有记录,mysql,sql,Mysql,Sql,我真的很好奇我是如何用这个查询删除记录的,包括 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

我真的很好奇我是如何用这个查询删除记录的,包括

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; 

Table学院具有“工程学院”和“通信学院”的价值观,而Table课程具有这两种价值观“测试”。查询的结果是删除了两个测试值,而不是工程学院的测试

创建临时表的查询被过滤到
colleges.COLLEGE\u NAME='COLLEGE of Engineering'
,因此它将只包含具有该值的行。
DELETE
语句使用完全相同的筛选,因此它将删除临时表中的所有行。

您注意到缺少的
?抱歉,我没有注意到。编辑