본문 바로가기
MySql

MySQL 한 테이블에서 다른 테이블로 한 열 복사

by 베이스 공부 2020. 12. 16.
반응형

where를 사용하여 한 테이블에서 다른 테이블로 열을 복사하는 방법에 대해 혼란 스럽습니다. SQL 쿼리를 작성했는데 트랜잭션 잠금 시간이 초과되었거나 쿼리가 둘 이상의 행을 반환한다고합니다.
using mysql
Basically,
나는 가지고있다:

Table 1:  Results
BuildID  platform_to_insert

Table 2:  build
BuildID correct_platform

update results set results.platform_to_insert 
     = (select correct_platform from  
       build where results.BuildID = build.BuildID)

 

해결 방법

 

하위 쿼리가 필요하다고 생각하지 않습니다.

UPDATE results, build
SET    results.platform_to_insert = build.correct_platform
WHERE  results.BuildID = build.BuildID

 

참조 페이지 https://stackoverflow.com/questions/2015527

 

 

반응형

댓글