Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 605DAB5DC69 for ; Mon, 5 Sep 2011 07:43:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 79691-03 for ; Mon, 5 Sep 2011 10:43:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from softlayer.compulab.co.il (50.23.254.54-static.reverse.softlayer.com [50.23.254.54]) by mail.postgresql.org (Postfix) with ESMTP id 24BB1B5DC5F for ; Mon, 5 Sep 2011 07:43:47 -0300 (ADT) Received: from [62.90.235.247] (port=50847 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.69) (envelope-from ) id 1R0WeY-00044l-LD for pgsql-general@postgresql.org; Mon, 05 Sep 2011 13:43:46 +0300 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 8CB377E9508 for ; Mon, 5 Sep 2011 13:43:45 +0300 (IDT) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 00Dg7jCU+JM8 for ; Mon, 5 Sep 2011 13:43:45 +0300 (IDT) Received: from [10.1.1.27] (sim-pc.compulab.local [10.1.1.27]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 21A5E7E9506 for ; Mon, 5 Sep 2011 13:43:45 +0300 (IDT) Message-ID: <4E64A79E.7030503@compulab.co.il> Date: Mon, 05 Sep 2011 13:42:38 +0300 From: Sim Zacks User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.20) Gecko/20110805 Lightning/1.0b2 Thunderbird/3.1.12 MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: conditional insert References: In-Reply-To: Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.812 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, KHOP_DYNAMIC=0.73, MIME_HTML_ONLY=0.723, TO_NO_BRKTS_HTML_ONLY=1.258 X-Spam-Level: X-Archive-Number: 201109/102 X-Sequence-Number: 179460 On 09/05/2011 01:37 PM, Pau Marc Muñoz Torres wrote:
i don't  see it clear, let me put an example

i got the following table

molec varchar(30)
seq varchar(100)

where I insert my values

 lets image that i have a record introduced as ('ubq', 'aadgylpittrs')

how i can prevent to insert another record where molec='ubq' ?

thanks

Either put a unique constraint on molec or do
insert into tbl(molec,seq)
select 'ubq', 'aadgylpittrs' where not exists(select molec from tbl where molec='ubq')