日期:2014-05-17  浏览次数:20855 次

求帮忙解答这两个问题...谢谢
1. select directorID, firstname,lastname from director where directorid in (select mvid from direct where mvid in(select mvid from movieinfo where rating != 'PG')); 这个转exists

2. 找出打分(ranking)第二多的用户的用户名和被打分电影的数量
求写出查询语句



下面是表

MovieInfo (mvID, title, rating, year, length, studio)
Director(directorID, firstname, lastname)
Member(username, email, password)
Actor(actorID, firstname, lastname, gender, birthplace)
Cast(mvID*, actorID*)
Direct(mvID*, directorID*)
Genre(mvID*, genre)
Ranking(username*, mvID*, score, voteDate)

谢谢

------解决方案--------------------
SELECT directorID,
firstname,
lastname
FROM director a
WHERE EXISTS
(SELECT 1
FROM direct b
WHERE a.directorid = b.mvid
AND EXISTS
(SELECT 1 FROM movieinfo c WHERE b.mvid = c.mvid AND c.rating != 'PG'
)
);