Skip to main content
added 277 characters in body
Source Link
ypercubeᵀᴹ
  • 98.6k
  • 13
  • 215
  • 305

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`;

or the simplified (for MySQL only):

SELECT t.id_task,  
       EXISTS (SELECT * FROM PROJECT_HAS_TASK AS pt 
               WHERE t.id_task = pt.id_task) 
         AS HasProject 
FROM TASK AS t;

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`;

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`;

or the simplified (for MySQL only):

SELECT t.id_task,  
       EXISTS (SELECT * FROM PROJECT_HAS_TASK AS pt 
               WHERE t.id_task = pt.id_task) 
         AS HasProject 
FROM TASK AS t;
deleted 24 characters in body
Source Link

Your solution maywill 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 `PROJECT``TASK`.`id_project``id_task`,  
CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `PROJECT``TASK`.`id_project``id_task` = `PROJECT_HAS_TASK`.`id_project``id_task`) 
     THEN 1 
     ELSE 0 
END as HasProject 
FROM `PROJECT`;`TASK`;

Your solution may 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 `PROJECT`.`id_project`,  
CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `PROJECT`.`id_project` = `PROJECT_HAS_TASK`.`id_project`) 
     THEN 1 
     ELSE 0 
END as HasProject 
FROM `PROJECT`;

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`;
added 3 characters in body
Source Link

Your solution may 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 `PROJECT`.`id_project`,  
CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `PROJECT`.`id_project` = `PROJECT_HAS_TASK`.`id_project`) 
     THEN 1 
     ELSE 0 
END as HasProject 
FROM `TASK`;`PROJECT`;

Your solution may 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 `PROJECT`.`id_project`,  
CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `PROJECT`.`id_project` = `PROJECT_HAS_TASK`.`id_project`) 
     THEN 1 
     ELSE 0 
END as HasProject 
FROM `TASK`;

Your solution may 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 `PROJECT`.`id_project`,  
CASE WHEN EXISTS (SELECT * FROM `PROJECT_HAS_TASK` WHERE `PROJECT`.`id_project` = `PROJECT_HAS_TASK`.`id_project`) 
     THEN 1 
     ELSE 0 
END as HasProject 
FROM `PROJECT`;
added 15 characters in body
Source Link
Loading
Source Link
Loading