본문 바로가기

IT/DB3

MySql 의 last_insert_id() https://cirius.tistory.com/1139 [MySQL] last_insert_id() 사용시 주의 많은 개발자들의 Database 관련 코드를 보면 심심치 않게 위험한 요소들을 가지고 있다. MySQL 를 다루면서 많은 실수를 하는 부분이 바로 Last_insert_id() 사용과 관련된 부분이다. 오늘은 잘못된 auto cirius.tistory.com - 하나의 insert 문에 대량의 정보를 insert 할 경우 INSERT INTO some_table ( contents, member_id ) VALUES ('이건 테스트1', 'bgjo'), ('이건 테스트2', 'bgjo'),('이건 테스트3', 'bgjo') 이면 last_insert_id()는 1 이라는. 따로따로 inser.. 2020. 6. 23.
[MySql] errno: 121 "Duplicate key on write or update" https://stackoverflow.com/questions/20512572/duplicate-key-on-write-or-update Duplicate key on write or update? Duplicate key on write or update First i will like to acknowledge the fact that, i have been to similar posts, but i couldn't find a way to solve this annoying issue which i face as of present.I am stackoverflow.com -> 해당 스키마에 똑같은 이름의 제약조건이 있는것. ex ) t_word 테이블에 외래키 제약 명을 fk_t_note 로 해.. 2020. 6. 21.
[mysql] select delete 동시에 하기 https://ojava.tistory.com/11 글의 내용임 DELETE FROM newsEval WHERE hnp_news_seq IN ( SELECT * FROM (SELECT eval.hnp_news_seq FROM newsEval AS eval LEFT JOIN hnp_news AS hnews ON eval.hnp_news_seq = hnews.news_id WHERE hnews.news_id IS NULL) AS result ) 포인트1 ) select * from으로 한번 더 select를 감싸주는 것. 포인트2) 서브쿼리의 테이블 명은 alias를 줘야함 여러개 요소일 때는 in 2018. 10. 18.