user3697028 user3697028 - 21 days ago 5x
SQL Question

Join two fields from one table to another

i have two table as follows


id name appid modifiedappid
--- --- ---- ------------
1 abc 1 2


id apllicationName
-- ---------------
1 App1
2 App2

when join these two table i need the below result

Name appname Modifiedappname
----- ------- ----------------
abc app1 app2


You need to Join Table2 twice

select Name , 
       B.apllicationName as appname,
       C.apllicationName as Modifiedappname
from Table1 A
Left join Table2 B on A.appid  =
Left join Table2 C on A.modifiedappid =

Note : If the values of appid & modifiedappid in Table1 will always have entry in Table2 then you can change theLeft Outer Join to INNER JOIN