Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Single-Column Values from Different Tables?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-01 : 01:08:19
Lynn writes "Single-Column Values from Different Tables? The scenario:
I have three tables: Users (internal); Contacts (external); Emails (both).
The Emails table has three relevant fields:
FROM: Holds an ID number (could be user or contact)
TO: Holds an ID number (could be user or contact)
DIRECTION: 0=internal; 1=external in; 2=external out
I know from the Direction field whether the From/To ID's are user or contact. ... But the query doesn't!
I want to return a recordset containing all emails to a specific user or contact. But I need to select UserName from the Users table or ContactName from the Contacts table, depending on the Direction field, into a single column called FromName. Can this be done?
Any help much appreciated - thanks."
   

- Advertisement -