Search Postgresql Archives

Re: Insert data if it is not existing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 25/05/18 14:35, Igor Neyman wrote:

'''INSERT INTO my_table(name, age)

VALUES( %s, %s)

WHERE NOT EXISTS(SELECT name FROM my_table WHERE name=%s)''', ('Scott', 23, 'Scott'))

I haven't been following this thread, so maybe this has already been said, but I think you need a SELECT in there as well:

insert into my_table(name, age)
select 'value 1', 'value 2'
where not exists (
  .....
);

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod@xxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux