Where() in (select) H2

随声附和 提交于 2019-12-11 03:06:06

问题


I have 2 kinds of software (both Java): One with MySSQL and the other with H2 database. My problem is that in MySQL I have this query:

Select * from X where (1,2,3) in (select 4,5,6 from Y)

But in H2 throw me this error:

Subquery is not a single column query; SQL statement:

I understand basically what this mean but I need to select all values from X that are in Y and I read that this is the most efficient way. The other way could be asign all the values from Y to a Java Object and then put them in to X but I know that this is not the "best" way to do it


回答1:


Try to modify the query to have single values

Select * from X where CONCAT(1,2,3) in (select CONCAT(4,5,6) from Y)

So instead of 3 columns you have one where all the 3 column values are joined



来源:https://stackoverflow.com/questions/46056328/where-in-select-h2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!