0

This is a different question because I have joined 2 tables. The solutions for the duplicate question indicated does not work for me. This is the query:

SELECT a.id, a.userName, IF(o.userId = 1, 'C', IF(i.userId = 1,'I','N')) AS relation
FROM tbl_users AS a
LEFT JOIN tbl_contacts AS o ON a.id = o.contactId
LEFT JOIN tbl_invites AS i on a.id = i.invitedId
ORDER BY relation

This returns the output as follows:

id username relation

1 ray C

2 john I

1 ray N

I need to remove the third row from the select query by checking if possible that id is duplicate. I tried adding distinct(a.id) but it doesn't work. How do I do this?

Maraboc
  • 10,550
  • 3
  • 37
  • 48
Saeesh Tendulkar
  • 638
  • 12
  • 30

0 Answers0