Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Unindo duas tabelas sem retornar linha indesejada

SELECT 
  IssueID, 
  AssignedID, 
  CreatorID, 
  AssignedUser.real_name AS AssignedName, 
  CreatorUser.real_name AS CreatorName
FROM Issues
  LEFT JOIN Users AS AssignedUser
         ON Issues.AssignedID = AssignedUser.UserID
  LEFT JOIN Users AS CreatorUser
         ON Issues.CreatorID = CreatorUser.UserID
ORDER BY `issueid` ASC
LIMIT 0, 30