Notice
Recent Posts
Recent Comments
Link
- Arawn's Dev Blog
- Outsider's Dev Story
- Toby's Epril
- Benelog
- NHN 개발자 블로그
- SK 플래닛 기술 블로그
- OLC CENTER
- 소프트웨어 경영/공학 블로그
- 모바일 컨버전스
- KOSR - Korea Operating System …
- 넥스트리 블로그
- 리버스코어 ReverseCore
- SLiPP
- 개발자를 위하여... (Nextree 임병인 수석)
- "트위터 부트스트랩: 디자이너도 놀라워할 매끈하고 직관…
- Learning English - The English…
- real-english.com
- 'DataScience/Deep Learning' 카테…
- Deep Learning Summer School, M…
- Deep Learning Courses
민서네집
MySQL - selectKey 사용하기 본문
[참고] http://www.okjsp.net/bbs?seq=137293
AUTO_INCREMENT 속성의 PK 컬럼값을 다른 컬럼에도 쓰고 싶은 경우 - 더구나 그 컬럼이 PK 컬럼을 참조하는 foreign key 인 경우, 그러면서 NOT NULL 속성으로 되어 있는 경우
<insert id="insert" parameterClass="Bean">
<selectKey resultClass="Integer" keyProperty="seq">
select ifnull(max(a),0)+1 from table
</selectKey>
INSERT INTO table (a, b, c) VALUES (#seq#, #b#, #seq#)
</insert>
이런 방법이 가장 맞는것 같다.
https://www.okjsp.net/bbs?seq=189887
< Inserting auto generated id using mybatis and return the generated id to java >
http://www.raistudies.com/mybatis/inserting-auto-generated-id-using-mybatis-return-id-to-java/
'Database > MySQL' 카테고리의 다른 글
CODE NAME 을 반환하는 MySQL Function (0) | 2013.06.07 |
---|---|
UPPER ID로 최상위노드 찾아가는 MySQL Function (0) | 2013.06.07 |
SQL state [HY000]; error code [1030]; Got error -1 from storage engine (0) | 2013.05.21 |
MySQL - AUTOCOMMIT 여부 확인하기 (2) | 2013.05.09 |
MySQL에서 millisecond 나 microsecond 단위로 저장하기 (0) | 2013.05.08 |
Comments