[SQL ] 語法上的差異性
(針對 SQL 語言的問題,用這個標題。請用 Ctrl+Y 砍掉這行)
資料庫名稱:
MySQL
資料庫版本:
內容/問題描述:
兩個語法是這樣的
1.
select no,name
from clerk
where not exists(
(select book_no from book where auth='lee')
except
(select book_no
from trade_detail natural join trade
where trade.no=clerk.no));
2.
select no,name from clerk
where not exists(
select * from book where auth='lee' AND NOT EXISTS (
select * from trade natural join trade_detail
where trade.no=clerk.no AND trade_detail.book_no=book.book_no));
以上兩個語法結果是相同的結果
問題是不懂not exists+except的做何種的運算方式??
跟not exists做兩次是一樣的運算
不知道有人肯幫分析一下not exists之後接except 是怎樣的執行結果??
小的難以頓悟~"~感謝幫忙!!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.39.6.229
※ 文章網址: http://www.ptt.cc/bbs/Database/M.1396589930.A.8B6.html
→
04/04 19:07, , 1F
04/04 19:07, 1F
→
04/04 19:08, , 2F
04/04 19:08, 2F
→
04/04 19:08, , 3F
04/04 19:08, 3F
→
04/04 19:10, , 4F
04/04 19:10, 4F
→
04/04 19:11, , 5F
04/04 19:11, 5F