I have the following sql query that would only insert if it does not already exist in the table
INSERT INTO message_log (message, from_id, to_id, match_id, unix_timestamp, own_account) VALUES('hi', 'tom', 'tom', '55640ec48a2aecab0e3c096c556f5435f4bb054c68930040', 33333, TRUE)
WHERE NOT EXISTS (SELECT 1 FROM message_log WHERE message = 'hi' AND from_id = 'tom' AND to_id = 'tom' AND match_id = '55640ec48a2aecab0e3c096c556f5435f4bb054c68930040' AND unix_timestamp = 33333)
However I get the following error
ERROR: syntax error at or near "WHERE"
LINE 2: WHERE NOT EXISTS (SELECT 1 FROM message_log where message = ...
^
What I am doing wrong?
SELECTin the query.INSERTstatement?