Workitem is the main table where Worker table contains information about the person such as name, userid etc. Workitem has two fields 1, Assigned by 2, Modified by both fields have userids.
I want to capture the names Assigned by and Modified by.
select * from workitem left join worker on workitem.assignedtoid = worker.id
SELECT wi.*,
w1.[name] AS AssignedToLastname,
w2.[name] AS AssignedByLastname
FROM workitem wi
LEFT JOIN worker w1
ON w1.id = wi.assignedtoid
LEFT JOIN worker w2
ON w2.id = wi.assignedbyid