You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

HQL查询未返回含空外键的TCI记录,请求修正查询语句

修改后的HQL查询语句
select t1.id, t1.createdOn, t1.location.name 
from TCI as t1 
where t1.archive = false 
and (
    t1.s6 <> '' 
    or t1.location is null 
    or (t1.location is not null and t1.location.name <> '' and t1.location.archive = false)
)
关键修改说明
  • 拆分原查询中嵌套过深的条件,让逻辑更清晰,同时保留t1.archive = false的基础过滤规则
  • 新增t1.location is null的判断,直接匹配location字段为空的TCI记录,解决这类记录无法返回的问题
  • 让t1.s6 <> ''作为独立判断分支,确保所有s6非空的记录,不管location是否为空或有效,都能被查询出来
  • 针对location非空的场景,保留原逻辑中location.name非空且location未归档的判断,和原有业务规则保持一致

内容的提问来源于stack exchange,提问作者Veena g

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 00:45:45