这是我的结构:
darkrp_player:
uid (Primary Key)
wallet
playerinformation:
uid (Foreign key to darkrp_player/primary key to display)
steamID
display:
uid (foreign key to darkrp_player + playerinformation)
steamID
wallet
基本上,我希望来自玩家信息的steamID和来自darkrp_player的钱包转移到使用uid进行显示。我真的不懂SQL,所以任何帮助都会受到赞赏。
答案 0 :(得分:2)
您可以使用JOIN从多个表中进行选择。以下是使用您提供的表格中的uid选择钱包和steamID的示例
SELECT p.wallet, i.steamID
FROM darkrp_player p
LEFT JOIN playerinformation i ON i.uid = p.uid;
(我将带有p和播放器信息的darkrp_player与i混淆)。
听起来您想要使用uid,steamID和钱包并将其插入显示表。你可以这样做:
INSERT INTO display (uid, steamID, wallet)
SELECT p.uid, p.wallet, i.steamID
FROM darkrp_player p
LEFT JOIN playerinformation i ON i.uid = p.uid;
答案 1 :(得分:0)
假设您只想在谈到" transfer"时加入数据,您只需加入表格即可:
SELECT playerinformation.uid, steamID, wallet
FROM darkrp_player
INNER JOIN playerinformation ON playerinformation.uid = darkrp_player.uid;