Your solution will cause performance problems if there will be larger number of records as there will be not index used in this JOIN statement:
 
    LEFT join (SELECT DISTINCT id_task FROM PROJECT_HAS_TASK)b on (a.id_task = b.id_task);

Probably you should try something using the EXISTS statement like this

    SELECT `TASK`.`id_task`,  
    CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `TASK`.`id_task` = `PROJECT_HAS_TASK`.`id_task`) 
      THEN 1 
      ELSE 0 
    END as HasProject 
    FROM `TASK`;