mysql - SQL 数据复制
问题描述
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 将只提供不同的记录。
推荐阅读
- android - 来自本地数据存储的 Parse.com 离线查询返回 0 个对象
- javascript - 如何在 html 输入中获取模式
- python - 如何使用 python 通过 V1 API 向 Watson Assistant 技能发送和附加新的上下文变量?
- android - 在其他方法中调用改造并将结果返回到主线程
- visual-studio-code - TextMate 语法和主题如何与 VSCode 一起使用?
- sql - SQL Join BETWEEN 日期计数问题
- java - 使用GET方法获取数据的Json结构android studio改造java
- html - Leaflet-routing-machine 未检测到通过 JavaOpenStreetMap 编辑器创建的新道路/节点/方式
- python-3.x - 如何从我的数据集中获取组合洛伦兹和高斯拟合的初始值?
- logstash - 我们如何在 ELK 的 logstash 中配置模块明智的配置