Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Join Help 1

Status
Not open for further replies.

Azathoth

Technical User
Jul 14, 2003
61
US
I'm having a bit of trouble joining all the information from the following tables into a temporary table. They all share some common element...I'm just not sure of the exact syntax for join. Help please?


tbl_eligibility_rule
-------------------------
|rule_name |
| |
|effective_date |
| |
|deferral_days |
| |
|rule_id |
|_______________________|


tbl_eligibility_sub_rule
-------------------------
|rule_id |
| |
|test_code |
| |
|result_code |
| |
|min_value |
| |
|max_value |
| |
|current_donation_only |
|_______________________|


lab_unit_test_result
-------------------------
|test_code |
| |
|result_code |
|_______________________|


tbl_lab_test
-------------------------
|test_code |
| |
|is_numeric |
|_______________________|

My "tables" look like crap, but you get the general idea. Thanks in advance.
 
In your database schema you must have the Primary Key and Foreign Key definitions.
The basic idea is to join on the FK = the PK of the reference table.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Let's say I want to join tbl_eligibility_rule with tbl_eligibility_sub_rule through the rule_id key...what would the syntax look like?
 
SELECT A.rule_name,A.effective_date,A.deferral_days,A.rule_id,B.test_code,B.result_code
FROM tbl_eligibility_rule A INNER JOIN tbl_eligibility_sub_rule B ON A.rule_id=B.rule_id

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top