Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

2 relationships between 2 tables - how can i query and return the correct results?

Posted on 2004-10-01
2
Medium Priority
?
212 Views
Last Modified: 2006-11-17
Two tables involved in this particular query:
STATUS and METHOD
in Status table, there are two fields that refer to the primary key of method table, as the status table is trying to catch how something was received and also how something was sent out. eg. sent out via courier, and returned via fax, for example.

I do not know how to write the SQL statement to bring back the correct results as it seems to be bringing back "Fax for both sent and received method, even though the sent method in the database is clearly courier.

Any one have any ideas?

The join looks like this:
STATUS join Method on Method.methodid = status.sentmethod
and Method.methodid = status.receivedmethod

I know this is not correct, but don't know how to resolve this....

Looking forward to your responses.

Peter
0
Comment
Question by:PeterL32
2 Comments
 
LVL 4

Accepted Solution

by:
ATAHAC earned 1000 total points
ID: 12203363
try his :
STATUS join Method m1 on m1.methodid = status.sentmethod
join Method m2 on m2.methodid = status.receivedmethod
0
 

Author Comment

by:PeterL32
ID: 12216288
Thanks so much, that works wonderfully!!!
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question