gary_j
asked on
conditional insert using exists (AGAIN!)
This statement returns an "Incorrect syntax near the keyword WHERE" error, and I don't understand why ...
INSERT INTO atable VALUES (list of column values) WHERE NOT EXISTS
(SELECT * FROM thesametable WHERE col_1 = 'something' And col_2 = 'somethingelse')
I know it has something to do with EXISTS; I confirmed that by removing the WHERE clause from the SELECT statement.
INSERT INTO atable VALUES (list of column values) WHERE NOT EXISTS
(SELECT * FROM thesametable WHERE col_1 = 'something' And col_2 = 'somethingelse')
I know it has something to do with EXISTS; I confirmed that by removing the WHERE clause from the SELECT statement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you very much!
INSERT INTO atable
SELECT (list of column values)
WHERE NOT EXISTS(SELECT * FROM thesametable WHERE col_1 = 'something' And col_2 = 'somethingelse')