pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Set Membership operator -- test group membership
3+ messages / 3 participants
[nested] [flat]

* Set Membership operator -- test group membership
@ 2005-06-14 19:08  Sophie Yang <yangsophie@yahoo.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Sophie Yang @ 2005-06-14 19:08 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: pgsql-novice@postgresql.org; pgsql-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.

Thanks!
Sophie


		
__________________________________ 
Yahoo! Mail Mobile 
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail 



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Set Membership operator -- test group membership
@ 2005-06-14 19:27  Igor Katrayev <igor.katrayev@nprb.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Igor Katrayev @ 2005-06-14 19:27 UTC (permalink / raw)
  To: pgsql-general@postgresql.org; +Cc: pgsql-novice@postgresql.org; pgsql-sql

Sophie,

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

Sincerely,

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
igor.katrayev@nprb.org


-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sophie Yang
Sent: Tuesday, June 14, 2005 11:09 AM
To: pgsql-general@postgresql.org
Cc: pgsql-novice@postgresql.org; pgsql-sql@postgresql.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.

Thanks!
Sophie


		
__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone. 
http://mobile.yahoo.com/learn/mail 

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





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [SQL] Set Membership operator -- test group membership
@ 2005-06-19 08:48  Oleg Bartunov <oleg@sai.msu.su>
  parent: Sophie Yang <yangsophie@yahoo.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Oleg Bartunov @ 2005-06-19 08:48 UTC (permalink / raw)
  To: Sophie Yang <yangsophie@yahoo.com>; +Cc: pgsql-general@postgresql.org; pgsql-novice@postgresql.org; pgsql-sql

Look contrib/intarray

On Tue, 14 Jun 2005, Sophie Yang wrote:

> 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.
>
> Thanks!
> Sophie
>
>
>
> __________________________________
> Yahoo! Mail Mobile
> Take Yahoo! Mail with you! Check email on your mobile phone.
> http://mobile.yahoo.com/learn/mail
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

 	Regards,
 		Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-06-19 08:48 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-06-14 19:08 Set Membership operator -- test group membership Sophie Yang <yangsophie@yahoo.com>
2005-06-19 08:48 ` Oleg Bartunov <oleg@sai.msu.su>
2005-06-14 19:27 Re: Set Membership operator -- test group membership Igor Katrayev <igor.katrayev@nprb.org>

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