

 Amazon Redshift は、パッチ 198 以降、新しい Python UDF の作成をサポートしなくなります。既存の 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 条件は、サブクエリ内に行が存在するかどうかをテストし、サブクエリが少なくとも 1 つの行を返した場合に true を返します。NOT が指定されると、条件はサブクエリが行を返さなかった場合に true を返します。

## 構文
<a name="r_exists_condition-synopsis"></a>

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

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

 EXISTS   
*table\_subquery* が少なくとも 1 つの行を返した場合に true となります。

NOT EXISTS   
*table\_subquery* が行を返さない場合に true になります。

 *table\_subquery*   
評価結果として 1 つまたは複数の列と 1 つまたは複数の行を持つテーブルを返します。

## 例
<a name="r_exists_condition-example"></a>

この例では、任意の種類の販売があった日付ごとに、1 回ずつ、すべての日付識別子を返します。

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

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