While executing join query I am getting duplicate data instead of the “distinct” keyword. I dim much more google and gained nothing. The table names are “Event” which holds list of events and the other table is UserEvents which assgins vents to users. On event can be assigned to multiple users. I am using SQL server 2005.
Events
eid | ename
-----------------
e1 | Test event1
e2 | test ecent2
UserEvents
id| uid | eventId
-----------------
1 | u1 | e1
2 | u1 | e2
3 | u2 | e1
Query:
select distinct
Events.eid, Events.ename,UserVents.uid
from
Events
inner join
UserEvents on
UserEvents.eventID=Events.eid
Output:
eid | ename | uid
-------------------
e1 | Test event1 | u1
e2 | Test event2 | u2
e1 | test event1 | u1
Issue:
Here, Event is repeating instead of the distinct key word. It should not repeat the event ‘e1″.
Kindly help me. How I change the query? Is this an issue in SQL server 2005??
kinly help
DISTINCTapplies to the whole column list. The whole row needs to be the same to be eliminated.The results you have put in your question are not complete as you have missed out the
uidcolumn.Returns
None of the rows are the same.