mysql 퀴리문 문의 정보
mysql 퀴리문 문의본문
INSERT UPDATE문이 아닌
이거 하나로 합친 명령어가 있던거 같은데.
이름이 무엇인가요??
데이터 존재 안하면 저장되고 존재하면 수정하고?
추천
0
0
댓글 4개

제가 알기론 그런건 없는데요~~ 잘못알고 계신거 아니신지

mysql 에 insert () ~~ ON DUPLICATE KEY ~~~ 가 있습니다.
INSERT INTO system_user
( system_user_name
, system_user_group_id
, system_user_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
('SYSADMIN'
, 1
, 1
,'Samuel'
,'the'
,'Lamanite'
, 1
, NOW()
, 1
, NOW())
ON DUPLICATE KEY
UPDATE first_name = 'Samuel'
, middle_name = 'the'
, last_name = 'Lamanite'
, last_updated_by = 1
, last_update_date = UTC_DATE();
INSERT INTO system_user
( system_user_name
, system_user_group_id
, system_user_type
, first_name
, middle_name
, last_name
, created_by
, creation_date
, last_updated_by
, last_update_date )
VALUES
('SYSADMIN'
, 1
, 1
,'Samuel'
,'the'
,'Lamanite'
, 1
, NOW()
, 1
, NOW())
ON DUPLICATE KEY
UPDATE first_name = 'Samuel'
, middle_name = 'the'
, last_name = 'Lamanite'
, last_updated_by = 1
, last_update_date = UTC_DATE();
아하 이거보고 적용해봤더니 완전 와방이네요 ㅋ
말씀하신건 replace 구문이신듯..
http://dev.mysql.com/doc/refman/5.0/en/replace.html
http://dev.mysql.com/doc/refman/5.0/en/replace.html