gpt4 book ai didi

sql - Informix SQL 查询 : Two similar queries returning different results

转载 作者:搜寻专家 更新时间:2023-10-30 22:22:56 25 4
gpt4 key购买 nike

我有一个返回一组行的 Informix SQL 查询。它针对我们一直在处理的网站的新版本略作修改,我们的 QA 注意到新版本返回不同的结果。经过调查,我们发现两个查询之间的唯一区别在于返回的字段数。

FROM、WHERE 和 ORDER BY 子句相同,SELECT 部分中的列名不影响结果。导致问题的只是字段的数量。

有什么想法吗?

最佳答案

添加 --+ ORDERED 连接顺序指令可以让您每次都以可预测的顺序获得结果,从而解决了这个问题。

链接指向指令如何工作的描述 http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls1144.htm

Use the ORDERED join-order directive to force the optimizer to join tables or views in the order in which they appear in the FROM clause of the query.

SELECT --+ ORDERED
name, title, salary, dname
FROM dept, job, emp WHERE title = 'clerk' AND loc = 'Palo Alto'
AND emp.dno = dept.dno
AND emp.job= job.job;

关于sql - Informix SQL 查询 : Two similar queries returning different results,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/305306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com