

 Amazon Redshift 將不再支援從修補程式 198 開始建立新的 Python UDFs。現有 Python UDF 將繼續正常運作至 2026 年 6 月 30 日。如需詳細資訊，請參閱[部落格文章](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)。

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

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

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

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

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

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

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

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

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

## 範例
<a name="r_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
...
```