Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where() in (select) H2

Tags:

java

mysql

h2

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

like image 922
Pedro Joaquín Avatar asked Oct 22 '25 15:10

Pedro Joaquín


2 Answers

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

like image 95
StanislavL Avatar answered Oct 25 '25 04:10

StanislavL


FYI version 1.4.200 seems to support this now

like image 44
Christian Beikov Avatar answered Oct 25 '25 06:10

Christian Beikov