Sharath N Sharath N - 1 year ago 55
Java Question

How to pass multiple search values in where condition

I connected to database in my java program. I have a situation where I need to pass filter values dynamically, filter values depends of others parts of java code

Example query: select * from table1 where id in (dynamic and multiple)?

How to pass these dynamic and multiple values using Java connection.

Answer Source

Try this

String query =  "select * from emp where id in(##)";

create the in clause like this

String inClause = "'abcd', 'cedf', '1234'";

String finalQuery = query.replace("##", inClause );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download