数据库mysql,xml文件里的sql语句怎样写?
数据库mysql,xml文件里的sql语句怎样写?
下面写了个模版给参考,resultMap只列举了2个字段id和create_time,根据实际修改即可
<resultMap id="ResultMap" type=“dto类型”>
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="selectByDate” parameterType="java.lang.String" resultMap="ResultMap">
select
*
from 表名
where date_format(时间字段名,'%Y%m') =DATE_FORMAT(#{传入的时间,jdbcType=TIMESTAMP}
, '%Y%m' )
</select>
SELECT * FROM 表名 WHERE DATE_FORMAT( 时间字段名, '%Y%m' ) = DATE_FORMAT( CURDATE( ) , '%Y%m' )