1
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'
正如您在上面看到的,我有一個查詢從其他表中提取信息並將其插入到名爲report的表中。我的問題是,原因是不是外鍵,我不知道如何使查詢與讓說:想知道如何使用select插入
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.
爲'reason'你想添加的「測試」串吧? ? –
這是正確的。所有(server_id,reported_id,reporting_id和admin_id)是對其他表的引用,但「reason」不是。那是一個塔內的「報告」 – Perelan