SQLTeam.com | Weblogs | Forums

Why are there so many rows

This query is supposed to be around 10k rows but is 1mill. Can you see any spot that is the cause of this?
select sv.last_name, sv.first_name, ed.event_name, wr.description as Worker_role from staff_view sv
inner join staff_worker_role_link_view wl
on sv.staff_id = wl.staff_id
inner join security_events se
on wl.worker_role_id = se.worker_role_id
inner join event_definition ed
on se.event_definition_id = ed.event_definition_id
inner join worker_role wr
on wl.worker_role_id = wr.worker_role_id
--where wr.description = ("Administrator")
where sv.end_date is null

One or more joins does not have all keys specified in the join. I'm guessing "security_events" but of course I don't know for sure. That is, a security event is not distinguished just by work_role_id but must have another key(s) specified to make it unique / the correct join conditions.

1 Like

I'm looking all over. I can't find an example how to join on more than one column.
like Join on this_table
nd join on that_ table