0

我有一个关于根据 2 个表匹配的字段将值设置为是或否的先前问题。我试图让查询检查generalsource.firstinventor,如果它匹配inventor.inventorfull插入“是”或插入“否”结果是以下代码:

UPDATE i
SET LeadInventor = 
    CASE 
        WHEN fi.FirstInventorName IS NULL THEN 'No' 
        ELSE 'Yes' 
    END
FROM Inventor i
    LEFT JOIN FirstInventor fi
    ON i.InventorFirst + ' ' + i.InventorLast = fi.FirstInventorName

效果非常好,直到我尝试放入 MySQL 并且我无法弄清楚语法有什么问题。我如何解决它?

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM Inventor i     LEFT JOIN FirstInventor fi     ON i.InventorFirst + ' ' + i.' at line 7
4

1 回答 1

2

CONCAT 字符串为

CONCAT( i.InventorFirst, ' ', i.InventorLast )

更新:另外,您的更新语句中似乎存在语法问题,应该如下

UPDATE 
  Inventor i
  LEFT JOIN FirstInventor fi ON CONCAT( i.InventorFirst, ' ', i.InventorLast ) = fi.FirstInventorName
SET LeadInventor = 
    CASE 
        WHEN fi.FirstInventorName IS NULL THEN 'No' 
        ELSE 'Yes' 
    END

更多信息:http ://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat

于 2013-04-02T15:31:20.143 回答