mysql - 删除帐户表中的重复项并更新关联记录

标签 mysql

我有表accounts,我想根据电子邮件地址从中删除重复项,表account中的每条记录在表booking<中都有一个预订,因此在从表 account 中删除重复项之前,我必须将预订记录关联到剩余的帐户。表 account 中最高的 account_id 将用于更新表 booking,所有其他表将被删除。

重复表是这样的:

This is the table accounts

预订表是这样的

This is the table: booking

更新后订 table 应该是这样的

Table booking after update

我该怎么做? 谢谢

最佳答案

谢谢@scaisEdge,但我已经用其他方式解决了, 我已在餐 table 预订中添加了临时电子邮件字段, 我已使用 account_id join 更新了电子邮件 我已使用电子邮件地址更新了餐 table 预订中的 account_id 最后我使用以下命令删除了表帐户中的重复项:NOT IN(select...)

关于mysql - 删除帐户表中的重复项并更新关联记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38673831/

相关文章:

php - 按列对 MySQL 数据库进行排序

php - 对话的数据库逻辑(如论坛)PHP、MySql

php - htaccess 的 mysql 数据安全吗?

mysql - 如何使用 MySQL 将内连接保存到新表

php - 查询数据并排列数据 Laravel

python - 1300, "Invalid utf8mb4 character string: '\xE2\x96\x88\xE2\x96\x88

javascript - Node.js MYSQL 检测查询的插入/更新完整性?

mysql - 错误 3098 (HY000) : The table does not comply with the requirements by an external plugin

php - 将 user_table 中的数据插入 currency_table

php - 如何在一系列链式选择框中填充 sql 查询结果?