【问题标题】:Operand should contain 1 column(s) I'm getting this error while executing delete query操作数应包含 1 列 我在执行删除查询时遇到此错误
【发布时间】:2017-05-25 23:05:03
【问题描述】:

这是我的 sql 查询

delete FROM 
SubMaster_test1 
where SubMasterId in (select * 
from SubMaster_test1 where AgentId 
not in (select distinct
introducer from SubMaster_test1 
where introducer is not null))

我收到以下错误

[Err] 1241 - 操作数应包含 1 列

【问题讨论】:

标签: mysql


【解决方案1】:

你应该只在“*”上写上“id”

delete FROM 
    SubMaster_test1 
    where SubMasterId in (select SubMasterId
    from SubMaster_test1 where AgentId 
    not in (select distinct
    introducer from SubMaster_test1 
    where introducer is not null))

【讨论】:

  • [Err] 1093 - 您无法在 FROM 子句中指定目标表 'SubMaster_test1' 进行更新...收到此错误
  • 我知道了。制作一个只有一列的临时表 id 并将这个 SubMasterId 插入其中然后使用该表删除数据
  • insert into temp select SubMasterId from SubMaster_test1 where AgentId not in(从 SubMaster_test1 中选择不同的介绍人,其中介绍人不为空)
  • 好的,我已经创建了 tem 表并插入了数据……接下来呢?
  • delete FROM SubMaster_test1 where SubMasterId in (select id from temp)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多