我希望您能为我提供正确的SQL语法。main_accounts (table1)'---id, group_name, account_name, payment_methodpayments (table2)'---id, account_name, payment_method我正在尝试做的是更新付款中的account_name行,其中payment_method等于payment_method表中的main_accounts。我试过了:update paymentsset account_name = (select account_name from main_accounts where payment_method = payment_method)WHERE payment_method = payment_method但是这是在说: #1242-子查询返回的行数超过1所以我不知道...我希望我可以这样做:update paymentsset account_name = (select account_name from main_accounts where payment_method = **{is equal to payment_method in main_accounts table}**此外,我希望可以以此为触发条件,以更新main_accounts表时,account_name自动转到payments table,当account_name与。 最佳答案 您收到该错误,因为您的子查询返回的值不止1个,而该值不能在SET语句中使用。在执行JOIN语句时,应该对其他有问题的表执行UPDATE。就像是UPDATE payments a JOIN main_accounts b ON a.payment_method = b.payment_methodSET a.account_name = b.account_name;关于mysql - 更新行检查重复项,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27207528/ 10-14 00:13