How would I search multiple (in this example, say 2) columns for an array of values?
For example, here is my table Documents
:
1. DocNumber (varchar)
2. CompanyCode (varchar)
3. Data1 (varchar)
4. Data2 (varchar)
5. Data3 (varchar)
DocNumber and CompanyCode form the composite primary key of this table. Say I have a set of values which I want to search in the database such as:
DocNumber | CompanyCode |
---|---|
1001 | 101 |
1002 | 102 |
1004 | 103 |
How would I find these unique combinations in the table with one query?
I could use in
:
select *
from Documents
where DocNumber in :docNumbers and CompanyCode in :companyCodes
But that would also return records with DocNumber 1001 and CompanyCode 102 (all combinations of the 2 lists). I want to avoid that.
I am using HANA DB (through a Spring Boot application).
Sample table data:
table data
Expected response:
expected response
Response I get:
current response