Solved

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

Posted on 2004-10-01
2
204 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 250 total points
Comment Utility
try his :
STATUS join Method m1 on m1.methodid = status.sentmethod
join Method m2 on m2.methodid = status.receivedmethod
0
 

Author Comment

by:PeterL32
Comment Utility
Thanks so much, that works wonderfully!!!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now