【发布时间】:2021-07-05 02:50:39
【问题描述】:
早安
我想根据两列匹配的值过滤掉行。两列都在同一个表中
不确定这是否可以在 WHERE 子句中完成?
ID = 12345 和 Country 为 null 当这两列匹配时,删除该行
谢谢
【问题讨论】:
标签: sql oracle filter oracle-sqldeveloper where-clause
早安
我想根据两列匹配的值过滤掉行。两列都在同一个表中
不确定这是否可以在 WHERE 子句中完成?
ID = 12345 和 Country 为 null 当这两列匹配时,删除该行
谢谢
【问题讨论】:
标签: sql oracle filter oracle-sqldeveloper where-clause
你可以用这个:
DELETE
FROM
table_name
WHERE
(ID = 12345 and Country is null);
```
# Or in a more "safe" way, use soft delete (adding a new column):
alter table [your table name] add is_deleted varchar2(1) default 'N';
update [your table name]
set is_deleted = 'Y'
where (ID = 12345 and Country is null);
【讨论】:
我想通了
其中 (ID != 12345) 或 (Country is not NULL) 这会保留具有该 ID 并具有 Country 的所有内容,但会删除 Country 为空值的行
【讨论】: