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

Set Membership operator -- test group membership

From: Sophie Yang <yangsophie(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Set Membership operator -- test group membership
Date: 2005-06-14 19:08:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-novicepgsql-sql
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. 


pgsql-novice by date

Next:From: operationsengineer1Date: 2005-06-14 19:18:10
Subject: PGDATA
Previous:From: Havasvölgyi OttóDate: 2005-06-14 16:31:09
Subject: Re: need suggestion for server sizing

pgsql-general by date

Next:From: Michal HlavacDate: 2005-06-14 19:15:10
Subject: Re: suse 9.2
Previous:From: Danny GaethofsDate: 2005-06-14 17:52:58
Subject: server not starting

pgsql-sql by date

Next:From: Igor KatrayevDate: 2005-06-14 19:27:30
Subject: Re: Set Membership operator -- test group membership
Previous:From: Tom LaneDate: 2005-06-14 13:37:22
Subject: Re: foreign key on pg_shadow

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