I have 3 tables:
session
SessID PK
Author
AbstractNo PK
SessID FK
Abstract
AbstractNo PK
I am currently searching the session table in a form. I want to be able to search the Abstract table by the Abstract.LastName. You can see the relationship.
My current query is giving me duplicate rows:
select distinct s.SessId as id, SessionCode as sessionCode, CAST(SessionTitle AS VARCHAR) as sessionTitle,s.TypeCd as typeCode,
SessDate as date,SC,SORTSC,datename(dw, SessDate) as dayOfWeek,ab.FAInitials, ab.FALastName,auth.LastName as Author, auth.Initials,
ab.AbstractNo,auth.AbstractNo from SESSION as s
inner join LUTYPE as t on s.TypeCd=t.TypeCd
left outer join ABSTRACT ab on s.SessID = ab.SessID
left outer join AUTHOR auth on ab.AbstractNo = auth.AbstractNo where auth.LastName = 'Wong'
order by id
My dupes look like this:
1, A23, 'topic 1',...........'Wong',E.C
2, A23, 'topic 1',...........'Wong',E.C
3, A20, 'topic 2',...........'Wong',A.
4, A20, 'topic 2',...........'Wong',H.M.
5, A20, 'topic 2',...........'Wong',T.
Is there any way to return just one of these rows per Author last Name?
I know they are different 'Wong's, but the query from the form is for a 'Wong'.