Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Doable? Left join to 2 tables but have same alias

Posted on 2013-02-03
2
Medium Priority
?
291 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 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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