gpt4 book ai didi

java - IN 子句中的 Hibernate 标准 DB2 复合键

转载 作者:行者123 更新时间:2023-12-01 16:05:33 25 4
gpt4 key购买 nike

Hibernate 标准使用 DB2 方言生成以下 SQL:IN 子句中包含复合键,但 DB2 回答查询不正确:

select * from tableA where (x, y) IN ( ( 'x1', y1) )

但是,DB2 抛出了这个:

SQL0104N  An unexpected token "," was found following ", y) in (
('x1'". Expected tokens may include: "+". SQLSTATE=42601

最佳答案

正确的语法是

从表 A 中选择 *,其中 (x, y) IN (VALUES ( 'x1', y1) )

请注意,您仅指定 VALUES 子句一次,因此可以获得多行结果

从表 A 中选择 *,其中 (x, y) IN (VALUES ( 'x1', y1), ( 'x2', y2) )

但是不知道如何让 Hibernate 做到这一点。

关于java - IN 子句中的 Hibernate 标准 DB2 复合键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2714530/

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