pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vernon Wu <vernonw@gatewaytech.com>
To: pgsql-sql@postgresql.org
Subject: Two-way query
Date: Thu, 27 Jun 2002 14:47:38 -0700
Message-ID: <MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko> (raw)

I need help to find an effective method to resolve a two-way query problem. 

Problem:
One is looking for friends who meet his criteria while people will not show up in his friend list if this person's criteria don't 
meet their criteria.

His criteria:
age: 24 ? 32
education: at least with a bachelor degree
occupation: programmer

DB tables:

profile:	id | age | education | occupation

preference:	id | age range | education set | occupation set

Search:

Batch of sql statements:
1.fetch this person's preference (select criteria)
2.Use his preference issue a query statement as:
select id from profile where (age < 33 and age > 23) and (education='bachelor' or education='master' or 
education='phd') and (occupation='programmer')
3.fetch preference with ids from the previous query.
4.Issue a similar query of the step 2 to find out whether he is qualified to be a friend of people in step 2

What is the most effective sql statement for this problem?


Thank in advance for your advice.

Vernon







Message-ID: <MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko>
Permalink:  ../MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko/
Also on:    postgresql.org/message-id/MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko

 · 

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: vernonw@gatewaytech.com
  Subject: Re: Two-way query
  In-Reply-To: <MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko>

* 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