[MyBatis]查询SQL得到一个数字

Mapper文件中写:

<select id="findExpiredCount" resultType="integer" parameterType="java.util.HashMap">
SELECT COUNT (*) as cnt from ${tableName} where created_datetime&lt;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

原文地址:https://www.cnblogs.com/heyang78/p/11647793.html