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
 General SQL Server Forums
 New to SQL Server Programming
 Regarding Get Data From More than one table

Author  Topic 

mailtosaja
Starting Member

28 Posts

Posted - 2008-08-11 : 03:43:47
Hi,
I have three table.structure and data display below..
Test1

TaskID R1 U1 U2
1 1202 41 null
2 1203 null 46
3 1204 null 47


U1_Table

U1 name
41 Test

U2_Table

U2 Name
46 function1
47 function2

i want the below structure data for the resourceID

TaskID ResourceID U1 U2
1 1202 Test --
2 1203 -- function1
3 1204 -- function2

Thanks in advance........


Thanks & Regards,
S.Sajan.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 03:47:00
[code]SELECT t1.TaskID,t1.R1 AS ResourceID,ISNULL(u1.name,'-') AS U1,ISNULL(u2.name,'-') AS U2
FROM Test1 t1
LEFT JOIN U1_Table u1
ON u1.U1=t1.U1
LEFT JOIN U2_Table u2
ON u2.U2=t1.U2[/code]
Go to Top of Page

mailtosaja
Starting Member

28 Posts

Posted - 2008-08-11 : 04:11:06
thanks visakh16
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-11 : 04:13:34
quote:
Originally posted by mailtosaja

thanks visakh16


you're welcome . learn about joins

http://www.sqlteam.com/article/writing-outer-joins-in-t-sql
Go to Top of Page
   

- Advertisement -