Multi field search query form
Appreciate if anyone can help me to solve the multi field search query from the following search form:
Field 1 = text field1
Field 2 = text field2
Field 3 = text field3
Field 4 = combobox1 and combobox2 (user can fill either one of this)
Field 5 = combobox3 and combo box4 and combobox5 (user can fill either one of this)
Please note that:
a. user can enter at least one variable from this form.
b. user can fill all the variables from this form.
c. Field 1, field 2 and field 3 is 'or' condition.
d. field 4 and field 5 is 'and' condition.
Example: if user fill in field 2, field 3 and field 5 combobox4, the sql query should be: select * from myTable where field 2 like '%textfield2%' or field 3 like '%textfield2%' and field 5 = 'combobox4';
Appreciate if anyone can construct the java code for this so that I can have a single query according to user input. Thank you.