In SQL Server, I am joining three tables like below.
select t1.empid, t2.sales, t3.date
from table1 t1
left outer join table2 t2 on t1.empid = t2.empid
left outer join table3 t3 on t1.empid = t2.empid
and t2.id= t3.id
Is this correct, I use and condition, thank you.
if i write the proc: i am joing the table using left outer join
select wrh.empid
from Tbl_F_Weekly_Report_Header WRH
left outer join Tbl_Emp_Master_M EM on wrh.EmpId =em.EmpId
LEFT outer join Tbl_F_Emp_Position_M EPS on WRH.PositionCode = EPS.PositionCode
where EM [Tbl_Emp_Master_M] doesnot contain Positioncode
is it correct
Your
LEFT OUTER JOINon table3 is incorrect. You just need:since you have already specified
t1.empid = t2.empidabove in the firstLEFT OUTER JOINYour updated query:
looks good, just make sure you include
FROM(was originally missing from your question)