WHERE
谓词支持子查询,包括
IN
、
NOT IN
、
EXISTS
、
NOT EXISTS
和标量子查询。 不支持以下类型的子查询:
嵌套子查询,即一个子查询内的另一个子查询
OR
中的
NOT IN
子查询,例如
a = 3 OR b NOT IN (SELECT c from t)
在大多数情况下,可以使用
NOT EXISTS
重写
NOT IN
子查询。 建议尽可能使用
NOT EXISTS
,因为执行带有
NOT IN
子查询的
DELETE
可能会速度较慢。
> DELETE FROM events WHERE date < '2017-01-01'
> DELETE FROM all_events
WHERE session_time < (SELECT min(session_time) FROM good_events)
> DELETE FROM orders AS t1
WHERE EXISTS (SELECT oid FROM returned_orders WHERE t1.oid = oid)
> DELETE FROM events
WHERE category NOT IN (SELECT category FROM events2 WHERE date > '2001-01-01')
INSERT
MERGE
PARTITION
query
UPDATE