1. 程式人生 > >1. mysql關鍵字 ---> exists

1. mysql關鍵字 ---> exists

部分 name where 就是 mys 關鍵字 exist -- sel

exists用於where關鍵字後,後面的條件語句一定是查詢語句且返回的是布爾類型。
例如:
select from a where exists (select b_id from b where b.b_name = a.a_name)
當條件語句select b_id from b where b.b_name = a.a_name有值時,就是true,就等同於執行了這個條件語句where後面的部分。那麽整個sql語句等同於:
select
from a where a_name in (select b_name from b)

1. mysql關鍵字 ---> exists