Re: sql question; checks if data already exists before inserted - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: sql question; checks if data already exists before inserted
Date
Msg-id 20060622073826.GD23150@svana.org
Whole thread Raw
In response to sql question; checks if data already exists before inserted  ("nuno" <wegein@gmail.com>)
List pgsql-general
On Wed, Jun 21, 2006 at 10:59:42PM -0700, nuno wrote:
> insert into student (studentid, fname, lname)
> select 'JORDANMICHAEL', 'Michale', 'Jordan' from student where
> studentid not in
> (select studentid from student);
>
> however, this does not seem to work. it does not insert data even if it
> does not exist in the database. hmm!

There are no NULL studentid's, right? Because that would make NOT IN do
something other than you think. Perhaps NOT EXISTS would work better.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Dynamic loading of C functions
Next
From: brian ally
Date:
Subject: Re: Help from Havana