使用 select 语句删除行
Using select statement to delete rows
我有以下查询:
SELECT a.* FROM id_stats a
join id_list b
on a.id = b.id
and a.start_date NOT between b.start_date::date and DATEADD(day,7,b.start_date::date)
returns 我想从 id_stats table 中看到的行,但是当我尝试删除时出现错误:
DELETE a FROM id_stats a
join id_list b
on a.id = b.id
and a.start_date NOT between b.start_date::date
and DATEADD(day,7,b.start_date::date)
错误:
SQL compilation error: syntax error line 1 at position 7 unexpected
'a'. syntax error line 2 at position 0 unexpected 'join'.
根据上面的评论,这里是解释语法的参考文档。没有 JOIN
也没有 ON
。是 using
和 where
。
https://docs.snowflake.com/en/sql-reference/sql/delete.html#syntax
DELETE FROM id_stats a
using id_list b
where a.id = b.id
and a.start_date NOT between b.start_date::date and DATEADD(day,7,b.start_date::date)
我有以下查询:
SELECT a.* FROM id_stats a
join id_list b
on a.id = b.id
and a.start_date NOT between b.start_date::date and DATEADD(day,7,b.start_date::date)
returns 我想从 id_stats table 中看到的行,但是当我尝试删除时出现错误:
DELETE a FROM id_stats a
join id_list b
on a.id = b.id
and a.start_date NOT between b.start_date::date
and DATEADD(day,7,b.start_date::date)
错误:
SQL compilation error: syntax error line 1 at position 7 unexpected 'a'. syntax error line 2 at position 0 unexpected 'join'.
根据上面的评论,这里是解释语法的参考文档。没有 JOIN
也没有 ON
。是 using
和 where
。
https://docs.snowflake.com/en/sql-reference/sql/delete.html#syntax
DELETE FROM id_stats a
using id_list b
where a.id = b.id
and a.start_date NOT between b.start_date::date and DATEADD(day,7,b.start_date::date)