Re: sql question; checks if data already exists before inserted

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: nuno <wegein(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sql question; checks if data already exists before inserted
Date: 2006-06-22 07:38:26
Message-ID: 20060622073826.GD23150@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message brian ally 2006-06-22 07:51:48 Re: Help from Havana
Previous Message Martijn van Oosterhout 2006-06-22 07:22:12 Re: Dynamic loading of C functions