I have spring boot application , in that in one of DAO class , we have one method where we are retrieving some data , for that we are using below query , here am using namedParameterJdbcTemplate
select student_id from student_records where create_date >= timestamp '"+appProps.getFromDate()+"' and create_date <= timestamp '"+appProps.getToDate()+"' and student_id in (:studentIdList)
the complete method is like below
public List<String> readMatchingStudentIds_ALL(List<String> inputStudentIdsList){
List<String> macthingStudentIdsList = new ArrayList<>();
try{
Map<String, List<String>> namedParameters = Collections.singletonMap("studentIdsList", inputStudentIdsList);
String query = " select student_id from student_records where create_date >= timestamp '"+appProps.getFromDate()+"' and create_date <= timestamp '"+appProps.getToDate()+"' and student_id in (:studentIdList)";
macthingStudentIdsList = namedParameterJdbcTemplate.queryForList(query, namedParameters, String.class);
}catch(Exception e)
{
throw new RuntimeException(e.getMessage(),e);
}
return macthingStudentIdsList;
}
everything working fine , but now problems coming , for example the incoming student is list contains "AFE1245" but in our db we have data like below "000AEF1245" , what i means 0's are prefixed , we do not know how many 0's are prefixed , for single query we can use LIKE operator like below
select student_id from student_records where student_id like '%input_student_id'
but my case is different as we need to use sql IN
clause , is their any possibility we can use sql IN
clause and LIKE
both or is their any other way