SQL练习题25:使用join查询方式找出没有分类的电影id以及名称

题目:

使用join查询方式找出没有分类的电影id以及名称
如输入为:

INSERT INTO film VALUES(1,‘ACADEMY DINOSAUR‘,‘A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies‘);
INSERT INTO film VALUES(2,‘ACE GOLDFINGER‘,‘A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China‘);
INSERT INTO film VALUES(3,‘ADAPTATION HOLES‘,‘A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory‘);

INSERT INTO category VALUES(1,‘Action‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(2,‘Animation‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(3,‘Children‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(4,‘Classics‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(5,‘Comedy‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(6,‘Documentary‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(7,‘Drama‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(8,‘Family‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(9,‘Foreign‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(10,‘Games‘,‘2006-02-14 20:46:27‘);
INSERT INTO category VALUES(11,‘Horror‘,‘2006-02-14 20:46:27‘);

INSERT INTO film_category VALUES(1,6,‘2006-02-14 21:07:09‘);
INSERT INTO film_category VALUES(2,11,‘2006-02-14 21:07:09‘);

 

程序:

SELECT a.film_id, a.title
FROM film as a
LEFT JOIN film_category as b
ON a.film_id = b.film_id
WHERE b.film_id ISNULL

 

SQL练习题25:使用join查询方式找出没有分类的电影id以及名称

上一篇:Penetration Test - Using_Scripting_in_Pen_Testing(4)


下一篇:SQL SERVER 2012/2016 删除数据库日志