0
PostgreSQL的語法錯誤,我有以下SQL查詢,只插入,如果它不存在於表中對於其中不存在
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)
不過,我得到以下錯誤
ERROR: syntax error at or near "WHERE"
LINE 2: WHERE NOT EXISTS (SELECT 1 FROM message_log where message = ...
^
什麼我做錯了?
有查詢沒有'SELECT'。 – joop
這不是你可以做的事情。至少不是那樣的。你能解釋一下你用INSERT語句來完成的任務嗎? – JNevill
@JNevill我希望行只能在表中不存在的情況下插入 – Arya