Set, SubSelect

From: "George Johnson" <gjohnson(at)jdsc(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Set, SubSelect
Date: 2000-12-28 15:31:31
Message-ID: NEBBJGKMGLGMDGBMOHJNGEHJCAAA.gjohnson@jdsc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello All,

I spent yesterday and last nite reading the mailing lists and manual about:

select * from tab1 where tab1.id in ('id1','id2','id3');
select * from tab1 where tab1.id in (select tab1.id from tab1,tab2
where tab1.id = tab2.id);
select * from tab1 where exists (select tab1.id from tab1,tab2 where
tab1.id = tab2.id);

Ok, and etc, etc.

I read how what I really need is a 2nd table whose foreign keys can link in
with the table. That would be great, but here is my scenerio:

I have around 1000 people who need to be able to store groups or 50-100
thousand numbers (saved search sets). These numbers refer back to other
tables etc. I'd love to be able to have a table like:

sset#1 sset#2
----------------------------------------
person #1 0,1,2,3,5 10,12,13,15
person #2 5,6,74,44 23,55,43

I'd additionally love to be able to simply:

select * from my_big_data_table where exists (select sset#1 from
saved_sets where person = person #1);

In MySQL, there was a "find_in_set" function which was very handy and
very fast. I tried the regex text string searching and really ended up
with pitiful lookup times. I also am going to try taking advantage of the
unlimited select/insert/update lines and just throw a huge constant at it
(if the JDBC driver for 7.1 accepts large selects ... the 7.0 version does
not).

I'd love to hear how you guys would approach this.

Sincerely,
George Johnson

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2000-12-28 16:12:04 Re: How I can join between the other database's tables?
Previous Message Hubert Hafner 2000-12-28 14:50:39 trouble with phpPgAdmin