查询错误 (1066): 表/别名不唯一: 'useraccounts'



我想从用户表中获取电子邮件和密码,其中电子邮件是主键,而对于电子邮件,我想从帐户id是外键的用户帐户中获取余额和帐户id。根据那个外键,我想要accountNo从表账户

SELECT `user`.`email`, `user`.`passwrd`, `useraccounts`.`Balance`, `useraccounts`.`AccountID`, `accounts`.`AccountNo`
FROM `user` , `accounts`
LEFT JOIN `useraccounts` ON `user`.`email` = `useraccounts`.`email` 
LEFT JOIN `useraccounts` ON `accounts`.`AccountID` = `useraccounts`.`AccountID` 
SELECT `user`.`email`, `user`.`passwrd`, `useraccounts`.`Balance`, `useraccounts`.`AccountID`, `accounts`.`AccountNo`
FROM `user` , `accounts`
LEFT JOIN `useraccounts` ON `user`.`email` = `useraccounts`.`email` 
LEFT JOIN `useraccounts` ON `accounts`.`AccountID` = `useraccounts`.`AccountID` 

错误为#1066-不是唯一的表/别名:useraccounts在此处输入图像描述

"你能纠正这个查询吗?plz"-也许这个

SELECT `user`.`email`, `user`.`passwrd`, `useraccounts`.`Balance`, `useraccounts`.`AccountID`, `accounts`.`AccountNo`
FROM `user` 
LEFT JOIN `useraccounts` ON `user`.`email` = `useraccounts`.`email` 
LEFT JOIN `accounts` ON `accounts`.`AccountID` = `useraccounts`.`AccountID` 

相关内容

  • 没有找到相关文章

最新更新