Search Postgresql Archives

Re: if exists...does it exists for insert statments?

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

 



--- On Tue, 12/11/07, Pau Marc Munoz Torres <paumarc@xxxxxxxxx> wrote:
> could i use a sentence similar to the mysql sentence
> 
> insert if not exist into SP values
> ('cesp','sp');
> 
> in postgresql?

Using standard ANSI-SQL the statement could be re-written:

INSERT INTO SP
     SELECT a, b
       FROM VALUES ( 'cesp', 'sp' ) AS tmp( a, b )
  LEFT JOIN Sp
         ON (Sp.col1,Sp.col2)=(tmp.a,tmp.b)
      WHERE (Sp.col1,Sp.col2) IS NULL;

Regards,
Richard Broersma Jr.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[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