sql查询
SELECT `user`.`email`,
`user`.`passwrd`,
`user`.`status`,
`useraccounts`.`Balance`,
`useraccounts`.`AccountID`, `accounts`.`AccountNo`,
wallet.Server_typ,wallet.DateBought,
wallet.LastDate,
wallet.Profit,
withdraws.walletAdrs,
withdraws.Amount,
withdraws.status AS WDStatus,
withdraws.message,
withdraws.Date
FROM `user`
LEFT JOIN `useraccounts` ON `user`.`email` = `useraccounts`.`email`
LEFT JOIN `accounts` ON `accounts`.`AccountID` = `useraccounts`.`AccountID`
LEFT JOIN wallet ON user.email = wallet.email
LEFT JOIN withdraws ON user.email = withdraws.email
WHERE user.type = 'user'
这是我的查询,它工作正常,但有很多针对电子邮件地址的记录。因此,我的电子邮件变得重复。每当我打电话时,只发送电子邮件,就会出现重复的记录。我只想要一封电子邮件。提前致谢
最佳答案
SELECT DISTINCT `user`.`email`, `user`.`passwrd`, `user`.`status`,`useraccounts`.`Balance`, `useraccounts`.`AccountID`, `accounts`.`AccountNo`,wallet.Server_typ,wallet.DateBought,wallet.LastDate,wallet.Profit,withdraws.walletAdrs,withdraws.Amount,withdraws.status AS WDStatus, withdraws.message, withdraws.Date
FROM `user`
LEFT JOIN `useraccounts` ON `user`.`email` = `useraccounts`.`email`
LEFT JOIN `accounts` ON `accounts`.`AccountID` = `useraccounts`.`AccountID`
LEFT JOIN wallet ON user.email = wallet.email
LEFT JOIN withdraws ON user.email = withdraws.email
WHERE user.type = 'user'
使用 DISTINCT 将仅提供不同的记录。
关于mysql - SQL数据重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58957363/