source

select insertion으로 어떻게 하는지 궁금합니다.

factcode 2023. 9. 26. 22:36
반응형

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

반응형