I’m trying to insert unique records in a MSSQL and Postgresql DB using insert into where not exists. But I am getting a incorrect syntax error as seen below. What am I doing wrong?
INSERT INTO settings (id, title, description)
VALUES (1, 'imageHeight', 'Image Height')
WHERE NOT EXISTS (Select * from settings where id = 1);
Error:
[Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax near the keyword ‘WHERE’.
Try this:
sql server sql fiddle
postgresql sql fiddle
WHEREis a filter for results which are not typically pertinent toINSERToperations.