반응형
    
    
    
  select insertion으로 어떻게 하는지 궁금합니다.
INSERT INTO report (server_id, reported_id, reporting_id, admin_id)
            SELECT s.server_id, rep.reported_id, ru.reporting_id, a.admin_id
            FROM server s, reported_user rep, reporting_user ru, admin a
            WHERE s.server_port = 'port'
            AND rep.reported_steam_id = 'id'
            AND ru.reporting_steam_id = 'id'
            AND a.admin_id = '0'
 
위에서 보신 것처럼 다른 테이블에서 정보를 가져와서 보고서라는 테이블에 삽입하는 쿼리가 있습니다.제 문제는 이유가 외국 열쇠가 아니라는 것과 어떻게 질문을 해야 할지 모르겠다는 것입니다.
INSERT INTO report (server_id, reported_id, reporting_id, admin_id, reason)
            SELECT s.server_id, rep.reported_id, ru.reporting_id, a.admin_id
            FROM server s, reported_user rep, reporting_user ru, admin a
            WHERE s.server_port = 'port'
            AND rep.reported_steam_id = 'id'
            AND ru.reporting_steam_id = 'id'
            AND a.admin_id = '0',
            "TEST"; // <-- Does not work. Trying to insert a text string here. 
이거 드셔보세요.
        INSERT INTO report (server_id, reported_id, reporting_id, admin_id, reason)
        SELECT s.server_id, rep.reported_id, ru.reporting_id, a.admin_id,"TEST"
        FROM server s, reported_user rep, reporting_user ru, admin a
        WHERE s.server_port = 'port'
        AND rep.reported_steam_id = 'id'
        AND ru.reporting_steam_id = 'id'
        AND a.admin_id = '0'
언급URL : https://stackoverflow.com/questions/34930464/wondering-how-to-do-it-with-select-insertion
반응형
    
    
    
  'source' 카테고리의 다른 글
| 정의('CONCATENATE_SCRIPTs', false)를 사용하도록 강제됨; 갑자기 (0) | 2023.09.26 | 
|---|---|
| SQLite 소스 코드 읽기를 어디서 시작해야 합니까? (0) | 2023.09.26 | 
| Python에서 SQL 문에 변수를 사용하는 방법은? (0) | 2023.09.26 | 
| JPA Cache: 보기의 테이블이 업데이트된 후 db 보기에서 업데이트된 결과를 가져오는 방법 (0) | 2023.09.26 | 
| MySQL에서 조인에 인덱스를 사용하도록 강제하는 구문은 무엇입니까? (0) | 2023.09.26 |