1. 程式人生 > 實用技巧 >select null from table,exists和not exists 關鍵字的理解和使用場合

select null from table,exists和not exists 關鍵字的理解和使用場合

關鍵字exists 和not exists AND select null from table

  • select null from table。

這句sql語句的作用:查詢表中的資料,如果有則返回為NULL ,就是把select * from table 中的所有資訊替換成NULL ,理解一下就比較簡單了。

圖解
在這裡插入圖片描述
在這裡插入圖片描述

  • exists 關鍵字

exists 這個關鍵字返回的為boolean 型別的,並不是一些資料關聯,如果條件成立。就返回為true ,表明這個條件成立,否則 false .

圖解
在這裡插入圖片描述
在這裡插入圖片描述
總結

select null from table 就是把符合查詢條件的資料所顯示的資料替換成NULL。exists 就是如果存在數,就是true ,不存在就為false 。