1
    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')

不工作 有什么问题

4

1 回答 1

1

尝试这个

 INSERT INTO `pages` (`subject_id`) VALUES ('102')
 ON DUPLICATE KEY UPDATE `content`='Updated' 
 WHERE `id`='21'
于 2013-07-17T13:28:22.313 回答