例如,我有以下表格:
account : ID, Login, Pass, Name
records : ID, Info, SubmitterID
并使用以下命令选择一些数据:
SELECT account.Name
, records.Info
FROM account, records
WHERE account.ID = records.ID
现在我想在records.SubmitterID = account.ID
有人知道这是否可能时显示名称字段?
感谢。
答案 0 :(得分:0)
我认为你可能想要的是:
SELECT account.Name, records.Info FROM account, records WHERE records.SubmitterID = account.ID
表格中的两个ID字段不应相互对应。
答案 1 :(得分:0)
SELECT a.Name
FROM account a
INNER JOIN records r ON (r.SubmitterID = a.ID)
答案 2 :(得分:0)
我可能会误解你的问题,买你为什么不用一个或陈述......
SELECT account.Name, records.Info
FROM account, records
WHERE account.ID = records.ID OR account.id=records.submitterID
答案 3 :(得分:0)
您有帐户 - > N:记录。 帐户和记录与account.ID = records.SubmitterID
相关Select account.name,records.info from ACCOUNT INNER JOIN records ON account.ID=records.SubmitterID