select distinct p.ProfId, p.FirstName,p.LastName,d.DeptName,
r.OverallAvg, r.NumOfRatings, DATE_FORMAT(r.LastRated, '%m/%d/%Y') as LastRated
from Professor p, department d
LEFT JOIN ratingsavg r ON p.ProfId = r.ProfId
where d.DeptId=p.DeptId and p.lastname like '%'
order by p.lastname, p.firstname LIMIT 0, 50