I wish to select data where two columns are in a set of pairs.
I have a MySQL query that works:
SELECT t.whatever
FROM t
JOIN
( VALUES (val1a, val2a), (val1b, val2b), ...) AS x (col1, col2)
ON x.col1 = t.col1
AND x.col2 = t.col2 ;
But when I try to use it in Java with parameters I can't get it working. This is what I've tried:
@Query(value = "SELECT t.whatever FROM t JOIN (VALUES (?1) AS x (col1, col2) ON x.col1 = t.col1 AND x.col2 = t.col2 ;", nativeQuery = true)
List<Whatever> findByPair(List<List<String>> PairString);
I get the following error: 'x' has more columns than were specified in the column list
Where PairString is a list of lists of strings such as:
[[val1a, val2a], [val1b, val2b], [val1c, val2c], [val1d, val2d]]