

 从补丁 198 开始，Amazon Redshift 将不再支持创建新的 Python UDF。现有的 Python UDF 将继续正常运行至 2026 年 6 月 30 日。有关更多信息，请参阅[博客文章](https://www.amazonaws.cn/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
...
```