mysql select id and name from other table and join query

select task.id, task.name, proj.id, proj.name
from tasks task left join projects proj on proj.id=task.project_id; 

Using left join ensures you get something even if there is no record in the projects table. If you want to ensure coherency, you may do

select task.id, task.name, proj.id, proj.name
from tasks task, projects proj
where proj.id=task.project_id; 

Leave a Comment