日期:2014-05-19  浏览次数:20844 次

兩SQL語句比較
各位,請幫個忙~~   下面兩條語句請問有什麼差異呢?請問可以寫出與“語句一”等價的表達式嗎?謝謝。
語句一:
SELECT   DISTINCT   CNAME
FROM   COURSES   C   WHERE   '男 '=all   (select   sex   from   enrolls,students   where   enrolls.sno=students.sno   and   enrolls.cno=C.cno)

語句二:
select   distinct   cname   from   courses,students,enrolls   where   students.sno=enrolls.sno   and   courses.cno=enrolls.cno   and   students.sex= '男 '

------解决方案--------------------
-------- =all -------
SELECT DISTINCT CNAME
FROM COURSES C WHERE '男 ' in (select sex from enrolls,students where enrolls.sno=students.sno and enrolls.cno=C.cno)
------解决方案--------------------
就是ALL的使用区别