当我尝试使用
WHERE NOT EXISTS
子句来防止在列age
中添加重复值的行时,出现了错误syntax error at or near "WHERE"
。为什么会出现语法错误?我正在使用Postgresql 9.1。
SQL
INSERT INTO live.users ("website", "age")
values ('abc', '123')
WHERE NOT EXISTS (SELECT age FROM live.users WHERE age = 123);
错误
ERROR: syntax error at or near "WHERE"
LINE 6: WHERE NOT EXISTS (SELECT age FROM live.users W...