728x90

Do not confuse Oracle SQL Statement with MySQL Statement

e.g) Oracle SQL statement code

OFFSET ____ ROWS FETCH NEXT _____ ROWS ONLY

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.company.helloBoard.domain.board.mapper.BoardMapper">
	
	<select id="getListBoard" parameterType="RequestList" resultType="Board">
		SELECT BOARD_ID
			 , WRITER
			 , TITLE
			 , CONTENT
			 , REG_DATE
			 , UPDATE_DATE
			 , DELETE_DATE
		  FROM BOARD
		  <where>
		  <if test="data.title != null and data.title != ''">
			 AND TITLE LIKE '%' || #{data.title} || '%'
		  </if>
		  <if test="data.writer != null and data.writer != ''">
			 AND WRITER LIKE '%' || #{data.writer} || '%'
		  </if>
		  </where>
	    OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
	</select>
	
	<select id="getListBoardCount" parameterType="Board" resultType="int">
		SELECT COUNT(*) AS CNT
		  FROM BOARD
		  <where>
		  <if test="title != null and title != ''">
			 AND TITLE LIKE '%' || #{title} || '%'
		  </if>
		  <if test="writer != null and writer != ''">
			 AND WRITER LIKE '%' || #{writer} || '%'
		  </if>
		  </where>
	</select>

</mapper>

 

 

e.g) 

<select id="pageList" parameterType="RequestList" resultType="OtpDto">
    SELECT
        A.id,
        B.service_name,
        B.group_name,
        A.otp_org_info_id,
        A.create_date,
        A.email,
        A.end_date,
        A.name,
        A.note,
        A.object_id,
        A.otp_app,
        A.user_id
    FROM
        ${data.uuid}_otp A,
        ${data.uuid}_hsm_service B
    <where>
        <if test="data.userId != null">
            AND A.user_id LIKE CONCAT('%', #{data.userId}, '%')
        </if>
        <if test="data.serviceName != null">
            AND B.service_name LIKE CONCAT('%', #{data.serviceName}, '%')
        </if>
        <if test="data.objectId != 0">
            AND A.object_id = #{data.objectId}
        </if>
    </where>
    ORDER BY A.create_date DESC
    LIMIT #{pageable.pageSize} OFFSET #{pageable.offset}
</select>

 

+ Recent posts