IF EXISTS (SELECT * FROM pages WHERE pages.id = 21)
UPDATE `pages` SET `content`='Updated' WHERE (`id`='21')
ELSE
INSERT INTO `pages` (`subject_id`) VALUES ('102')
不工作 有什么问题
答案 0 :(得分:1)
试试这个
INSERT INTO `pages` (`subject_id`) VALUES ('102')
ON DUPLICATE KEY UPDATE `content`='Updated'
WHERE `id`='21'