Suppose I've Below tables
student :
id Name
-------------------
1 john
2 carlos
3 zoya
4 arab
5 amir
and,
email :
id email student_id
--------------------------
1 a@mail.com 1
2 b@mail.com 2
3 c@mail.com 2
4 d@mail.com 3
5 e@mail.com 4
and Using sql query to get student name along with emails,
SELECT student.name, email.eid FROM student
INNER JOIN email
ON student.id = email.student_id
and it will give below output,
Name eid
-------------------
john a@mail.com
carlos b@mail.com
carlos c@mail.com
zoya d@mail.com
amir e@mail.com
here the duplicate entry(not actually duplicate) for carlos
returned,
but i want only single student list for example like this, ( either b@gmail.com
or c@gmail.com
doesn't matter).
Name eid
-------------------
john a@mail.com
carlos b@mail.com
zoya d@mail.com
amir e@mail.com
I've not much experience in sql,
I've used DISTINCT
but it wont works .. please help
Not : I'm storing emails in different tables in case if there is need in future.