Two-way query - Mailing list pgsql-sql

From Vernon Wu
Subject Two-way query
Date
Msg-id MA0RQOJIE6397GEGWS75KHHEE9I.3d1b87fa@kimiko
Whole thread Raw
List pgsql-sql
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
criteriadon'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






pgsql-sql by date:

Previous
From: q u a d r a
Date:
Subject: pg_user and pg_group
Next
From: terry
Date:
Subject: Re: graphical interface - admin