3

My query is like this:

select * from plat_customs_complex
where (code_t,code_s) 
in (('01013090','10'),('01029010','90'));

It runs well in psql console. My question is how to perform this query in client code.(via C# or Java)

And I already know the following code works well(C#):

string[] codeT = new string[]{"01013090","01029010"};    
connection.Query("SELECT * FROM plat_customs_complex WHERE code_t=ANY(@CodeT)",
new { CodeT = codeT });
0

1 Answer 1

1

Finally, I found the unnest function can help.

Pure SQL is like that:

select * from plat_customs_complex
where (code_t,code_s) = ANY(select * from unnest(ARRAY['01013090','01029010'],ARRAY['10','90']))

Can convert it to C# code easily:

string[] codeTs = new string[]{"01013090","01029010"}; 
string[] codeSs = new string[]{"10", "90"};
connection.Query("select * from plat_customs_complex
where (code_t,code_s) = ANY(select * from unnest(@CodeTs, @CodeSs))", 
new {CodeTs=codeTs, CodeSs=codeSs});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.