Re: [GENERAL] sql question; checks if data already exists before

2006-06-23 Thread Kostas Maistrelis
nuno wrote: >hi, there. i'm trying to write a SQL statement which does the following >things. > >1. checks if data already exists in the database >2. if not, insert data into database otherwise skip. > > > Check this thread : http://archives.postgresql.org/pgsql-general/2005-10/msg01787.php

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

2006-06-22 Thread Guy Rouillier
nuno wrote: > hi, there. i'm trying to write a SQL statement which does the > following things. > > 1. checks if data already exists in the database > 2. if not, insert data into database otherwise skip. > > for example, i'd like to insert a student called 'Michael Jordan' > whose ID is 'JORDANM

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

2006-06-22 Thread Martijn van Oosterhout
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 >

[GENERAL] sql question; checks if data already exists before inserted

2006-06-21 Thread nuno
hi, there. i'm trying to write a SQL statement which does the following things. 1. checks if data already exists in the database 2. if not, insert data into database otherwise skip. for example, i'd like to insert a student called 'Michael Jordan' whose ID is 'JORDANMICHAEL' only if the id, 'JORD