在MSSQL中它正在运行;
IF EXISTS (SELECT id FROM T1 WHERE id=X)
BEGIN INSERT INTO T1(C1, C2, C3)
(SELECT C1, C2, 'Different Value' AS C3 FROM T1 WHERE id=X)
END
MYSQL的对应语法是什么。
提前谢谢
答案 0 :(得分:1)
只需:
INSERT INTO T1(C1, C2, C3)
SELECT C1, C2, 'Different Value' AS C3
FROM T1
WHERE id=X
如果记录id = X存在,则将插入,否则不插入。