Delete语句有效,但不会删除行

时间:2020-03-19 12:28:17

标签: sql teradata teradata-sql-assistant

我想做出一条删除语句,要在该语句上删除另一个选定表中的某些文章。 我创建了该语句,但是当我运行它时,它不会删除某些内容。它正在运行,但没有删除任何行。

delete from article  where (client_id, art_no) in ( select art_no, client_id from art_del as A 
inner join (select distinct client_id from article) as D on a.cliend_id = d.client_id 
where label not in (0,-1));

where子句中的数据看起来不错,但是当我执行删除操作时,它不会删除某些内容。

1 个答案:

答案 0 :(得分:2)

where子句是这样的:

where (client_id, art_no)

因此该对具有第一个client_id,然后是art_no 但是在子查询中,顺序是不同的:

select art_no, client_id

更改为:

delete from article  
where (client_id, art_no) in ( 
  select client_id, art_no
  from art_del as A inner join (
    select distinct client_id 
    from article
  ) as D on a.cliend_id = d.client_id 
  where label not in (0,-1)
);
相关问题