일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 잡토이 메이킹 코딩 학원
- jobtoy
- 오라클
- 운정
- html5
- 코딩
- 유니티
- jsp
- 라즈베리파이
- 톰캣
- 파주
- 강좌
- 예제
- 아두이노
- 스크래치
- librecad
- s4a
- MSSQL
- 설치
- 잡토이
- tomcat
- Spring Security
- 리브레캐드
- Android
- Unity
- 안드로이드
- 설정
- oracle
- mysql
- 시작하기
Archives
- Today
- Total
랩제이
[mybatis] order by 동적 쿼리 본문
[mybatis] order by 동적 쿼리
다음처럼 하면 order by를 동적으로 삽입 할 수 있다.
* java
String orderKind = "wbsalecount";
Map<String, Object> condition = new HashMap<String, Object>();
condition.put("orderKind" , orderKind );
* mybatis
<select id="selDomainMap1" parameterType="java.util.Map" resultMap="libroBestsellerResultMap">
...
<trim prefix="ORDER BY">
<if test="orderKind == 'wbrank'"> A.WB_RANK ASC </if>
<if test="orderKind == 'wbsalecount'"> A.WB_SALE_COUNT DESC </if>
</trim>
...
</select>
[mybatis] order by 동적 쿼리
'programming > mybatis' 카테고리의 다른 글
[mybatis] IN qeury 사용하기 (0) | 2014.09.23 |
---|---|
[mybatis] where 1=1 는 <where> 로 바꾸어 주세요 (0) | 2014.06.20 |