我正尝试将事务中的所有transaction_subcategory_id更新为匹配中的match_subcategory_id,其中匹配中的match_name与事务中的transaction_subcategory_name相同。MySql加入查询问题
它一定是简单的,只是没有得到很远吧...
这是我们的最新尝试...
UPDATE transaction JOIN match ON match.match_name = transaction.transaction_name
SET transaction.transaction_subcategory_id = match.match_subcategory_id;
表
match
--------------------------
match_id
match_name
match_subcategory_id
transaction
--------------------------
transaction_id
transaction_name
transaction_subcategory_id
您在您的SQL语法中有错误;检查与您的MySQL服务器版本相对应的手册,以找到正确的语法,以便在第2行'JOIN match ON match.match_name = transaction.transaction_name'附近使用。 – user611468
您的SQL语法有错误;请检查与您的MySQL服务器版本相对应的手册,以便在第1行匹配'match SET transaction.transaction_subcategory_id = match.match_subcategory_id W'附近使用正确的语法。 – user611468
是,匹配是保留字。必须将其放在反引号中@ user611468编辑查询。 – Jacob