【问题标题】:Delete statement are working but doesn't delete rows删除语句正在工作,但不删除行
【发布时间】:2020-06-30 14:15:51
【问题描述】:

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

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 子句中的数据看起来不错,但是当我使用 delete 执行时,它不会删除任何内容。

【问题讨论】:

  • 如果您单独运行 select,它会返回任何内容吗?
  • 是的,它返回我想要的.. @jarlh
  • 返回多个art_no和client_id
  • 如果你这样做select from article where (client_id, art_no) in...,你会得到一些结果吗?
  • @OmariVictorOmosa ,它返回 0 行

标签: sql teradata teradata-sql-assistant


【解决方案1】:

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)
);

【讨论】:

  • 我改了,在 where/select 列的顺序一样,where(art_no,client_id), select art_no,client_cd ... 还是一样的问题
  • 您在问题中发布的代码是错误的。如果您仍然无法获得您想要的结果,这意味着您的代码逻辑错误或您的实际数据与您想象的不同。无论如何,没人能猜出问题出在哪里。
猜你喜欢
  • 1970-01-01
  • 2018-06-27
  • 2012-06-17
  • 1970-01-01
  • 2013-04-02
  • 2019-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多