Solved

Doable? Left join to 2 tables but have same alias

Posted on 2013-02-03
2
286 Views
Last Modified: 2013-02-03
I have a table that has some data in it. I created a new table but I cant get rid of the old one. For old/orig data, I still want to go to table1 and get the info. Anyway I can have the same alias for both the old and new table so I could pull data from both tables? This is what I have:

SELECT
nmp.id AS nonMemberProviderId,
ipn.id AS nonMemberPatientId,
ISNULL(CAST(dfl.id AS VARCHAR(MAX)),'') AS fileRowId
...

from
 .....
  LEFT JOIN dbo.Doc_Files_Letter dfl ON dfl.patientId = ipn.id
  LEFT JOIN dbo.LetterFiles dfl ON dfl.patientId = ipn.id
0
Comment
Question by:Camillia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
liija earned 500 total points
ID: 38849111
No, same alias cannot be used twice.
But with the same script you could unite the data from two tables - depending on your data like this:

SELECT
nmp.id AS nonMemberProviderId,
ipn.id AS nonMemberPatientId,
ISNULL(CAST(dfl.id AS VARCHAR(MAX)), CAST(dfl_new.id AS VARCHAR(MAX)) AS fileRowId
...

from
 .....
  LEFT JOIN dbo.Doc_Files_Letter dfl ON dfl.patientId = ipn.id
  LEFT JOIN dbo.LetterFiles dfl_new ON dfl_new.patientId = ipn.id
0
 
LVL 7

Author Comment

by:Camillia
ID: 38849186
let me try
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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