---
source_url: https://docs.dolphindb.cn/zh/error_codes/s02042.html
fetched_at: 2026-05-19T09:10:00Z
category: error_codes
title: S02042
sha1: 8f6954128f015c4b0519cc499f54101091ff9c50
---

# S02042

## 错误代码

S02042

## 报错信息

Distributed queries do not support the ‘exists’ keyword. RefId:S02042

## 错误原因

在分布式表查询中，WHERE 子句不支持 EXISTS 关键字。以下示例将导致错误：

```dolphindb
dbName = "dfs://test"
if (existsDatabase(dbName)) {
	dropDatabase(dbName)
}
t = table(2023.01.01..2023.01.03 as tradeDate)
db = database(dbName, VALUE, 2023.01.01..2023.01.03)
pt = db.createPartitionedTable(t, `pt, `tradeDate)
pt.append!(t)

select * from pt where exists(select * from t where t.tradeDate=pt.tradeDate)
```

## 解决办法

将上面的查询语句修改为如下语句：

```dolphindb
select pt.* from pt left semijoin t on t.tradeDate=pt.tradeDate where t.tradeDate!=NULL
```
