ID存成String类型 排序会按字符串排序,只需要这样就好了
<select id="datalistPage" parameterType="page" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
where 1=1
<if test="pd.keywords!= null and pd.keywords != ''"><!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件
字段1 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
or
字段2 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
-->
)
</if>
order by -ID DESC
</select>
参考http://originwxit.iteye.com/blog/1189515