I am implementing a search in which users need to fill different fields to do the search, but I am not sure how to search if user does not fill some of the fields.
Lets say I am asking them to fill name,family,age,city and country
User may leave any of these blank so I should make a search based on the filled one.
For example if name and family are filled just search for name AND family and if name, family and country are filled, search for records that has all of these three.
I am using prepared statement, How about if I use Persitance API?
ps.setString(1, "Name");
ps.setString(2, "Family");
ps.setint(3, "age");
ps.setString(4, "city");
ps.setString(5,"country");
Query
SELECT * FROM Customer WHERE name = ? AND family = ? AND age = ? AND city = ? AND country = ?