Use of CASE statement in a MySQL query I have 3 tables:

TASK (id_task (PRIMARY KEY), name) 
PROJECT (id_project (PRIMARY KEY), name)
PROJECT_HAS_TASK (id_project, task_id)


PROJECT_HAS_TASK is the (n,m) relation between PROJECT and TASK.

I'd like to return all the TASK records and a boolean value indicating if the task_id also exists in PROJECT_HAS_TASK. Is that possible to do with a SQL query? Or should I use a stored procedure?

EDIT :
Yes it is possible to do it with a SQL query. Thanks to both a1ex07 and bummi's help I ended up with this solution :

SELECT a.id_task,  
Case WHEN b.id_task IS NULL then 0 else 1 end as HasProject 
from TASK a
LEFT join (SELECT DISTINCT id_task FROM PROJECT_HAS_TASK)b on (a.id_task = b.id_task);
If you need to check if there is any project that has task, use something like    

SELECT a.id_task,  
Case WHEN b.id_task IS NULL then 0 else 1 end as HasProject 
from TASK a
LEFT join (SELECT DISTINCT id_task FROM PROJECT_HAS_TASK)b on (a.id_task = b.id_task)
;
-- if you need number of tasks for a project
Select  a.id_task,
COUNT(b.id_project) as num_projects
from TASK a
LEFT join PROJECT_HAS_TASK b on a.id_task = b.id_task
GROUP BY a.id_task;