gpt4 book ai didi

mysql - 查询错误 (1066) : Not unique table/alias: 'useraccounts'

转载 作者:行者123 更新时间:2023-11-29 15:30:14 24 4
gpt4 key购买 nike

我想从用户表中获取电子邮件和密码,其中电子邮件是主键,针对电子邮件,我想从用户帐户中获取余额和帐户 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 enter image description here

最佳答案

“你能更正这个查询吗” - 也许是这个

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`

关于mysql - 查询错误 (1066) : Not unique table/alias: 'useraccounts' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58787326/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com