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 [email protected] 1
2 [email protected] 2
3 [email protected] 2
4 [email protected] 3
5 [email protected] 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 [email protected]
carlos [email protected]
carlos [email protected]
zoya [email protected]
amir [email protected]
here the duplicate entry(not actually duplicate) for carlos
returned,
but i want only single student list for example like this, ( either [email protected]
or [email protected]
doesn't matter).
Name eid
-------------------
john [email protected]
carlos [email protected]
zoya [email protected]
amir [email protected]
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.