

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# EXISTS 條件
<a name="exists_condition"></a>

EXISTS 條件會檢定在子查詢中是否存在列，如果子查詢傳回至少一列，則傳回 true。如果指定 NOT，則此條件會在子查詢未傳回任何列時傳回 true。

## 語法
<a name="exists_condition-synopsis"></a>

```
[ NOT ] EXISTS (table_subquery)
```

## 引數
<a name="exists_condition-arguments"></a>

 EXISTS   
當 *table\$1subquery* 傳回至少一列時，其值為 true。

NOT EXISTS   
當 *table\$1subquery* 未傳回任何列時，其值為 true。

 *table\$1subquery*   
子查詢，會評估包含一個或多個欄和一列或多列的資料表。

## 範例
<a name="exists_condition-example"></a>

此範例會針對具有任何類型銷售的日期，傳回所有的日期識別碼，一次一個：

```
select dateid from date
where exists (
select 1 from sales
where date.dateid = sales.dateid
)
order by dateid;

dateid
--------
1827
1828
1829
...
```