java - change the select criteria according to a multiple select -


i have html page contain multiple select field, according selection display information sql table liek this.

select * mytable x="1" or x="2" 

the problem because i'm having multiple select dont know how many number of conditions should provide sql query. if have single selection multiple select field, query this:

select * mytable x="1" 

but if have 3 selections query this:

select * mytable x="!" or x="2" or x="3" 

so how can write dynamically changing query in java can handle single or multiple or selections??

use sql in avoid situation. this:

// crude way create sql in part // ideally should iterating on selections , creating string string selections = firstselection + "," + secondselection;  select * mytable x in(selections); 

Comments