how can left join two table on multiple column???
-
hi to all i have two table same below : tableA with this columns: ID CodeGuid Name Family --------------------- and tableB with this columns: ID CodeGuid mycomulns ---------------------------- i want to left join this two table on ID and CodeGuid but i dont want use code same this: select * from tableA Left JOIN tableB on (tableA.ID = tableB.ID) UNION select * from tableA Left JOIN tableB on (tableA.CodeGuid= tableB.CodeGuid) ---------------------------- is there another way to handle this output ? thanks in advance
-
hi to all i have two table same below : tableA with this columns: ID CodeGuid Name Family --------------------- and tableB with this columns: ID CodeGuid mycomulns ---------------------------- i want to left join this two table on ID and CodeGuid but i dont want use code same this: select * from tableA Left JOIN tableB on (tableA.ID = tableB.ID) UNION select * from tableA Left JOIN tableB on (tableA.CodeGuid= tableB.CodeGuid) ---------------------------- is there another way to handle this output ? thanks in advance
If both columns must match:
SELECT
...
FROM
tableA
LEFT JOIN tableB
ON tableA.ID = tableB.ID
AND tableA.CodeGuid = tableB.CodeGuidIf either column can match:
SELECT
...
FROM
tableA
LEFT JOIN tableB
ON tableA.ID = tableB.ID
OR tableA.CodeGuid = tableB.CodeGuid
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer