Google Answers Logo
View Question
 
Q: Explain how Relations work in SQL (specifically postgres) ( No Answer,   0 Comments )
Question  
Subject: Explain how Relations work in SQL (specifically postgres)
Category: Computers > Operating Systems
Asked by: climbingboulder-ga
List Price: $10.00
Posted: 08 Jan 2003 17:02 PST
Expires: 08 Jan 2003 17:07 PST
Question ID: 139558
I have a fair amount of experience using mysql and postgres, but on a
fairly simple level.  My current task is to use "relations" to
simplify some queries.  The table structure is as follows:

____table_1__________
id  data1 data2 data3

____table_2__________
id email misc_data

the relationship is that table 2 may have many records with the same
email address; however, the id field is unique for that record.

Table 1 contains many records for each id.

What I need to do is get all the records in table 1 for a given email
address.  If I wrote it in pretendSQL, I would write it as "SELECT *
FROM table_1 WHERE program IN (SELECT id FROM table_2 WHERE email =
'$given_email_address');

I think this might be a sub-select (again, I'm not experienced in
complex SQL queries).  This is NOT what I want.  Nor do I want to do a
join, if I can avoid it.  A friend gave me a brief explanation, but
he's now unavailable.  But basically, what he said was that you can
set up a relation between the the id and the email address, such that
you can just query table_1 as if the email address was actually a
field.  In other words,
"SELECT * FROM table_1 WHERE email = '$given_email_address';

How would I do this using a relation, and can you give me the short
introduction to what is happening and how I can set this up in
postgres.
I suspect it's fairly simple and straightforward, and I'm pretty
perceptive.  So give me the skinny. :-)
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy