我正嘗試將事務中的所有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