[SQL ] 語法上的差異性

作者: oklp1415 (天生我材)   2014-04-04 13:38:48
(針對 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 是怎樣的執行結果??
小的難以頓悟~"~感謝幫忙!!
作者: bohei (run and fall)   2014-04-04 19:07:00
撇開上半部一樣的不看差別就在一個使用not exists 一個使用exceptexcept不就是排除嗎?當然就跟not exists一樣摟我覺得你會搞混是因為你想把一整句sql一次看完你可以試著從內圈的括弧開始看

Links booklink

Contact Us: admin [ a t ] ucptt.com