0

我正在尝试使用以下代码更新 mysql(xamp) 中的列-

UPDATE firm SET `fk_contact_details_id` = SELECT 'id' FROM contact_details WHERE contact_details.name = firm.name

但我收到以下错误:

*#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 'SELECT 'id' FROM contact_details WHERE   
contact_details.name = firm.name' at line 1*

谁能告诉我我的陈述有什么问题吗?

4

1 回答 1

0

代替 :

SELECT 'id'

利用

SELECT id

完整查询:

UPDATE firm 
    SET `fk_contact_details_id` = (
        SELECT 
            id 
        FROM 
            contact_details 
        WHERE 
            contact_details.name = firm.name
        LIMIT 1
    )
于 2013-07-05T07:45:22.963 回答