java - Getting records from database with variable condition -


i'm trying lists of records id in specific set. set application via web service. should write query this: select * tbl_data id in (?, ?, ?, ?). problem (?, ?, ?, ?) part variable length. 1 request like: select * tbl_data id in (?, ?, ?) , like: select * tbl_data id in (?, ?, ?, ?, ?, ?). don't loop , records 1 one. there way build query?

you can generate in part of query in code. if know should instead of ? symbol, run loop , build it.

string sqlpart = "("; (every symbol last){ sqlpart += symbol; sqlpart += ","; } sqlpart += lastsymbol; sqlpart += ")";  string sql = "select * tbl_data id in " + sqlpart; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -