Skip site navigation (1) Skip section navigation (2)

Re: Set Membership operator -- test group membership

From: "Igor Katrayev" <igor(dot)katrayev(at)nprb(dot)org>
To: <pgsql-general(at)postgresql(dot)org>
Cc: <pgsql-novice(at)postgresql(dot)org>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Set Membership operator -- test group membership
Date: 2005-06-14 19:27:30
Message-ID: 67622181058673409D58D1DA2B0457410A6D3D@aoos-nprb-sbs.aoos-nprb.local (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-novicepgsql-sql

The sql like this:
  select * from tbl1 where (a, b) in ((1, 20), (2, 30), (3, 50));
works very well in PostgreSQL 8,


Igor Katrayev, Data Systems Manager
North Pacific Research Board
1007 West Third Avenue, Suite 100
Anchorage, AK 99501
Phone: 907-644-6700
Fax:   907-644-6780

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Sophie Yang
Sent: Tuesday, June 14, 2005 11:09 AM
To: pgsql-general(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org; pgsql-sql(at)postgresql(dot)org
Subject: [GENERAL] Set Membership operator -- test group membership

Say I have a table tbl1 with two columns:
   tbl1(a integer, b integer, c integer)

I want to select the rows in which a and b are members of a list of
integer pairs. The SQL in my mind is something like:
  select * from tbl1 where (a, b) in ((1, 20), (2, 30), (3, 50));

I know the SQL above does not work in PostgreSQL. I wonder what is the
proper way to use in PostgreSQL. I tried "select * from tbl1 where (a,
b) in ('{{1, 20}, {2, 30}, {3, 50}}')", and it doesn't work either.


Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone. 

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

pgsql-novice by date

Next:From: operationsengineer1Date: 2005-06-14 19:34:43
Subject: Re: PGDATA - SOLVED
Previous:From: operationsengineer1Date: 2005-06-14 19:18:10
Subject: PGDATA

pgsql-general by date

Next:From: Együd CsabaDate: 2005-06-14 19:37:31
Subject: How to set an expiration date for a WHOLE user account
Previous:From: Michal HlavacDate: 2005-06-14 19:15:10
Subject: Re: suse 9.2

pgsql-sql by date

Next:From: Greg Sabino MullaneDate: 2005-06-15 02:06:20
Subject: Re: getting details about integrity constraint violation
Previous:From: Sophie YangDate: 2005-06-14 19:08:39
Subject: Set Membership operator -- test group membership

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group