I have many case to search database, so i don't want repeat if/else statement, is there an other good solution ? nom and dd and ddd are input name,
Sorry for my bad english!
I have many case to search database, so i don't want repeat if/else statement, is there an other good solution ? nom and dd and ddd are input name,
Sorry for my bad english!
String requete = "Select * from employees where 1=1 ";
if (!nom.isEmpty()) {
requete += " and last_name like '"+nom+"%'";
}
if (!dd.isEmpty() && !ddd.isEmpty()) {
requete += " and hire_date between '"+dd+"' and '"+ddd+"';
}
This way you can optimiz, so you can get rid of the same if condition in the else block.