I prefer the first one.
By giving the fields a more specific name than just Id
or Name
, it's easier to see that you are joining correctly, and you don't have to use aliases for the fields if you select fields from more than one table:
select s.StudentId, s.StudentName, m.MentorId, m.MentorName
from Student s
inner join Mentor m on m.MentorId = s.MentorId
vs.
select s.Id as StudentId, s.Name as StudentName, m.Id as MentorId, m.Name as MentorName
from Student s
inner join Mentor m on m.Id = s.MentorId
Also, the word Name
is a reserved keyword in some databases (for example SQL Server), so it's not always practical to use as field name.