1. 程式人生 > 資料庫 >sql 常用標籤 函式

sql 常用標籤 函式

SELECT
            id,
            total,
            article_address,
            article_title,
            article_content,
            send_time,
            create_time,
            userId
        FROM push_message_log
        <if test=" startTime != '' and startTime != null ">
            where create_time > #{startTime}
        </if>
        <if test=" endTime != '' and endTime != null ">
            and create_time &lt; #{endTime}
        </if>
        <if test="offset != null and limit != null">
            limit #{offset}, #{limit}
        </if>
select * from sys_user 
		<where>
			<if test="createUserId != null">
				and `create_user_id` = #{createUserId} 
			</if>
			<if test="username != null and username.trim() != ''">
				and `username` like concat('%',#{username},'%') 
			</if>
		</where>
		<choose>
			<when test="sidx != null and sidx.trim() != ''">
				order by ${sidx} ${order}
			</when>
			<otherwise>
				order by user_id desc
			</otherwise>
		</choose>
		<if test="offset != null and limit != null">
			limit #{offset}, #{limit}
		</if>
SELECT
            count( 1 )
        FROM
            edu.edu_wx_rotate_user_open
        WHERE
            PERIOD_DIFF( date_format( now( ) , '%Y%m' ) , date_format( create_time, '%Y%m' ) ) =1
        AND `type` = '7'
 SELECT
              name ,
              count yesTotal
            FROM
                edu.miniprogram_kf_upper
            WHERE
                DATE_FORMAT(create_time, '%Y%m%d' ) = DATE_FORMAT( CURDATE( ), '%Y%m%d' )- 1 and wx_id is null and type=7
delete from sys_user where user_id in 
		<foreach item="userId" collection="array" open="(" separator="," close=")">
			#{userId}
		</foreach>
		;
		delete from sys_user_role where user_id in 
		<foreach item="userId" collection="array" open="(" separator="," close=")">
			#{userId}
		</foreach>