pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jean-Luc Lachance <jllachan@nsd.ca>
To: Rajesh Kumar Mallah. <mallah@trade-india.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: enforcing with unique indexes..
Date: Mon, 07 Oct 2002 11:55:10 -0400
Message-ID: <3DA1AE5E.5BA92B6B@nsd.ca> (raw)
References: <200210051219.07553.mallah@trade-india.com>

Try a rule or a triger that checks for 
NOT EXISTS ( select 1 from eyp_listing where group_id = New.group_id and
userid != New.userid) 



"Rajesh Kumar Mallah." wrote:
> 
> Hi ,
> 
> can anyone tell me how can i enforce below in a table.
> I want that no more that one distinct userid exists for a given group_id
> in the table.
> 
> ie i want 1 to 1 mapping between group_id and userid so that , there shud not be a
> single group_id having more that one kind of userid.
> 
> SELECT  group_id  from eyp_listing group by group_id  having  count(distinct userid) > 1  ;
> 
> always returns empty.
> 
> can it be done with some sort of UNIQUE INDEX?
> 
> Regds
> MAllah.
> 
> --
> Rajesh Kumar Mallah,
> Project Manager (Development)
> Infocom Network Limited, New Delhi
> phone: +91(11)6152172 (221) (L) ,9811255597 (M)
> 
> Visit http://www.trade-india.com ,
> India's Leading B2B eMarketplace.
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)



view thread (4+ messages)

Message-ID: <3DA1AE5E.5BA92B6B@nsd.ca>
Permalink:  ../3DA1AE5E.5BA92B6B@nsd.ca/
Also on:    postgresql.org/message-id/3DA1AE5E.5BA92B6B@nsd.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jllachan@nsd.ca, mallah@trade-india.com
  Subject: Re: enforcing with unique indexes..
  In-Reply-To: <3DA1AE5E.5BA92B6B@nsd.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox