distinct不得不用,ORA-01795: 列表中的最大表达式数为 1000

项目中出错一个错误,排查了半天,忽然发现控制台里面有这个错误:

ORA-01795: 列表中的最大表达式数为 1000

看了一下SQL语句:

select eer.teachclass_id
  from entity_elective_retive eer,
       entity_course_info     ci,
       entity_course_active   ca,
       entity_teach_class     tc
 where ci.id = '000001'
   and ca.course_id = ci.id
   and eer.teachclass_id = tc.id
   and tc.open_course_id = ca.id

 

发现上面的结果集有1052条,然后在第二个SQL的in语句里面使用了这个结果:

select key_id
  from entity_elective_retive
 where teachclass_id in ('2273','3022','3441','3684')
   and SCORE_TYPE_CJ = '2'

 

最终报出上面这个红色错误。

 

发现这个1052条对于第二次的查询来说完全是有冗余数据,所以可以使用distinct将其重复结果删除掉:

select distinct eer.teachclass_id
  from entity_elective_retive eer,
       entity_course_info     ci,
       entity_course_active   ca,
       entity_teach_class     tc
 where ci.id = '000001'
   and ca.course_id = ci.id
   and eer.teachclass_id = tc.id
   and tc.open_course_id = ca.id
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值