1

In case of select with named parameter query with like where qualifier ,we are using like below.

final String sqlQuery = "select  e.COMM,  e.DEPTNO,  e.EMPNO,  e.ENAME from EMP e where
 JOB like :JOB"
 Map namedParameters = new HashMap();
 namedParameters.put("JOB", "");
 List result = namedParameterJdbcTemplate.queryForList(sqlQuery, namedParameters);

How will be select with named parameter query with between where qualifier?

4
  • are you using Prepared Statement ??? Commented Feb 27, 2013 at 11:39
  • Your SQL syntax is incorrect, the BETWEEN values should not be within brackets. Commented Feb 27, 2013 at 11:43
  • I have no idea what you are asking Commented Feb 27, 2013 at 11:43
  • I am using Prepared statement Commented Feb 27, 2013 at 11:55

1 Answer 1

1
final String sqlQuery =
    "SELECT e.id, e.name, e.salary, e.dept FROM emp e "
    + "WHERE e.salary BETWEEN ? AND ?";

If you are using PreparedStatement then example:

pst.setLong(1,Long.parseLong(searchCriteria.getTransactionNo()));
pst.setLong(2,Long.parseLong(searchCriteria.getTransactionNo()));
Sign up to request clarification or add additional context in comments.

1 Comment

This is for select simple query.I want the query for select with named parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.