[ibatis] sql문 예제1 select
<select id="AuthGrpMenu.selectList" parameterClass="java.util.Map" resultClass="authGrpMenu" >
<![CDATA[
SELECT
ROW_NUMBER() OVER(ORDER BY tbl2.DISP_ORDER ASC) AS rowNo,
tbl2.MENU_ID AS menuId,
tbl2.MENU_NM AS menuNm,
tbl2.DISP_ORDER AS dispOrder,
tbl2.LVL AS lvl,
tbl2.UPPER_MENU_ID AS upperMenuId,
tbl2.MENU_URL AS menuUrl,
tbl2.USE_YN AS useYn,
tbl1.AUTH_GRP_CD AS authGrpCd,
tbl1.REG_DT AS regDt,
tbl1.REG_ID AS regId,
tbl1.MOD_DT AS modDt,
tbl1.MOD_ID AS modId,
(CASE WHEN tbl1.AUTH_GRP_CD > 0 THEN 'Y' ELSE 'N' END) AS authYn
FROM (
SELECT *
FROM dbo.AUTH_GRP_MENU
]]>
<dynamic prepend="WHERE">
<isNotEmpty property="sAuthGrpCd" prepend="AND">
<![CDATA[
(AUTH_GRP_CD = #sAuthGrpCd#)
]]>
</isNotEmpty>
</dynamic>
<![CDATA[
) tbl1
RIGHT OUTER JOIN dbo.MENU_TREE tbl2
ON (tbl1.MENU_ID = tbl2.MENU_ID)
]]>
<dynamic prepend="WHERE">
<isNotEmpty property="sUpperMenuId" prepend="AND">
<![CDATA[
(tbl2.UPPER_MENU_ID = #sUpperMenuId#)
]]>
</isNotEmpty>
<isNotEmpty property="likeUpperMenuId" prepend="AND">
<![CDATA[
(tbl2.UPPER_MENU_ID LIKE #likeUpperMenuId#)
]]>
</isNotEmpty>
<isNotEmpty property="sLvl" prepend="AND">
<![CDATA[
(tbl2.LVL = #sLvl#)
]]>
</isNotEmpty>
<isNotEmpty property="sUseYn" prepend="AND">
<![CDATA[
(tbl2.USE_YN = #sUseYn#)
]]>
</isNotEmpty>
<isNotEmpty property="sAuthYn" prepend="AND">
<![CDATA[
(tbl1.AUTH_GRP_CD > 0)
]]>
</isNotEmpty>
</dynamic>
</select>
--------------------------------------------------------------------------------------------------------
<select id="MenuTree.selectCount" parameterClass="java.util.Map" resultClass="java.lang.Integer">
<![CDATA[
SELECT
COUNT(*) AS rowCountAll
FROM dbo.MENU_TREE tbl1
]]>
<dynamic prepend="WHERE">
<isNotEmpty property="sMenuId" prepend="AND">
<![CDATA[
(tbl1.MENU_ID = #sMenuId#)
]]>
</isNotEmpty>
<isNotEmpty property="sLvl" prepend="AND">
<![CDATA[
(tbl1.LVL = #sLvl#)
]]>
</isNotEmpty>
<isNotEmpty property="sUpperMenuId" prepend="AND">
<![CDATA[
(tbl1.UPPER_MENU_ID = #sUpperMenuId#)
]]>
</isNotEmpty>
<isNotEmpty property="sUseYn" prepend="AND">
<![CDATA[
(tbl1.USE_YN = #sUseYn#)
]]>
</isNotEmpty>
</dynamic>
</select>
--------------------------------------------------------------------------------------------------------
<select id="PopupNotice.selectList" parameterClass="java.util.Map" resultClass="popupNotice" >
<![CDATA[
SELECT
ttbl1.rowNo,
ttbl1.authGrpCd,
ttbl1.adminId,
ttbl1.seqNo,
ttbl1.systemGbn,
ttbl1.msgGbn,
ttbl1.noticeContents,
ttbl1.confirmYn,
ttbl1.regDt,
ttbl1.regId,
ttbl1.modDt,
ttbl1.modId
FROM (
SELECT
ROW_NUMBER() OVER(ORDER BY tbl1.AUTH_GRP_CD ASC, ADMIN_ID ASC, SEQ_NO DESC) AS rowNo,
tbl1.AUTH_GRP_CD AS authGrpCd,
tbl1.ADMIN_ID AS adminId,
tbl1.SEQ_NO AS seqNo,
tbl1.SYSTEM_GBN AS systemGbn,
tbl1.MSG_GBN AS msgGbn,
tbl1.NOTICE_CONTENTS AS noticeContents,
tbl1.CONFIRM_YN AS confirmYn,
tbl1.REG_DT AS regDt,
tbl1.REG_ID AS regId,
tbl1.MOD_DT AS modDt,
tbl1.MOD_ID AS modId
FROM dbo.POPUP_NOTICE tbl1
]]>
<dynamic prepend="WHERE">
<isNotEmpty property="sAuthGrpCd" prepend="AND">
<![CDATA[
(tbl1.AUTH_GRP_CD = #sAuthGrpCd#)
]]>
</isNotEmpty>
<isNotEmpty property="sAdminId" prepend="AND">
<![CDATA[
(tbl1.ADMIN_ID = #sAdminId#)
]]>
</isNotEmpty>
<isNotEmpty property="sConfirmYn" prepend="AND">
<![CDATA[
(tbl1.CONFIRM_YN = #sConfirmYn#)
]]>
</isNotEmpty>
</dynamic>
<![CDATA[
) ttbl1
]]>
<dynamic prepend="WHERE">
<isNotEmpty prepend="AND" property="pMinRowNo">
<![CDATA[
(ttbl1.rowNo >= #pMinRowNo#)
]]>
</isNotEmpty>
<isNotEmpty prepend="AND" property="pMaxRowNo">
<![CDATA[
(ttbl1.rowNo <= #pMaxRowNo#)
]]>
</isNotEmpty>
</dynamic>
</select>
---------------------------------------------------------------------------------------------------------
<select id="ZipCd.select.any" parameterClass="java.util.Map" resultClass="ZipCd.object">
<![CDATA[
SELECT
$fields$
FROM $table$
]]>
<dynamic prepend="WHERE">
<isNotEmpty prepend="AND" property="ZIP_CD">
<![CDATA[
([ZIP_CD] = #zipCd#)
]]>
</isNotEmpty>
</dynamic>
<dynamic prepend="GROUP BY">
<isNotEmpty prepend="AND" property="group">
<![CDATA[
$group$
]]>
</isNotEmpty>
</dynamic>
<dynamic prepend="ORDER BY">
<isNotEmpty prepend="AND" property="sort">
<![CDATA[
$sort$
]]>
</isNotEmpty>
</dynamic>
</select>
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
[ibatis] sql문 예제1 select
'programming > ibatis mybatis' 카테고리의 다른 글
[ibatis] sql문 예제4 update (0) | 2013.06.25 |
---|---|
[ibatis] sql문 예제3 delete (0) | 2013.06.25 |
[ibatis] sql문 예제2 insert (0) | 2013.06.25 |
MySQL 쿼리결과에서 특정컬럼 값 받기 - selectKey (0) | 2012.03.21 |
ibatis에서 MSSQL OPENQUERY이용하기 (0) | 2012.03.21 |