I have a table with profiles. If there is a profile for user #:userId, I want to UPDATE it. If there is no profile for that user, I want to INSERT it. I tried this SQL query, but it did not work:
INSERT INTO profiles
SET name = :name,
website = :website,
bio = :bio
WHERE user = :userId
重复密钥更新
名称=:名称,
网站=:网站,
生物 = :生物
“用户”是主键
编辑:我在我的 SQL 中发现了一个错误,当它看起来像这样时,它工作得很好:
插入配置文件
SET user = :userId, -- <-- 错误在这里
名称=:名称,
网站=:网站,
生物 = :生物
重复密钥更新
名称=:名称,
网站=:网站,
生物 = :生物
感谢大家!