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的表中。我的问题是;原因不是外键,我不知道怎么用查询来说:
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.
答案 0 :(得分:1)
试试这个
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'