티스토리 뷰
Error/DB
[MariaDB]Error Code: 1093. Table 't_co_dept' is specified twice, both as a target for 'INSERT' and as a separate source for data 0.000 sec
IT공부블로그 2019. 4. 24. 10:31728x90
반응형
Error Code: 1093. Table 't_co_dept' is specified twice, both as a target for 'INSERT' and as a separate source for data
INSERT INTO `t_co_dept` VALUES
( (select max(dept_seq + 0) + 1 from t_co_dept ) );
위 에러는 해당 테이블에서의 조회된값을 바탕으로 해당테이블을 조작하면 안된다는것
INSERT INTO `t_co_dept` VALUES
( (select dep from (select max(dept_seq + 0) + 1 as dep from t_co_dept ) a)
위와 같이 별칭을 정해주고 서브쿼리를 이용하면 가능하다
728x90
반응형
'Error > DB' 카테고리의 다른 글
[MySQL] Column 'emp_seq' in field list is ambiguous (0) | 2019.06.16 |
---|---|
[MySQL] error code : 1222 (0) | 2019.05.15 |
[DB] max() 함수 사용시 column이 varchar일 경우 (0) | 2019.05.03 |
댓글