[MyBatis]查询SQL得到一个数字
Mapper文件中写:
<select id="findExpiredCount" resultType="integer" parameterType="java.util.HashMap"> SELECT COUNT (*) as cnt from ${tableName} where created_datetime<to_date(#{date},'yyyy-MM-dd') and created_user='12344' </select>
Java代码中写:
Map<String, String> expiredMap = new HashMap<String, String>(); expiredMap.put("tableName", tableName); expiredMap.put("date", dateExpiredStr); int countExpired = session.selectOne("findExpiredCount", expiredMap);
--END-- 2019-10-10