我需要执行一个条件包含子查询的查询。 那就是查询
SELECT CASE
WHEN EXISTS (SELECT * FROM `contatti_t_interazioni` `iz`
WHERE `iz`.`id_interesse` = `i`.`id_interesse`) THEN "si"
ELSE "no"
end AS `Interazioni`
FROM ((((`contatti_t_interessi` `i`
LEFT JOIN `contatti_t_proposte` `p` ON(( `i`.`id_interesse` = `p`.`id_interesse` )))
LEFT JOIN `v_anagrafica_utenti` `a` ON(( `i`.`id_utente` = `a`.`id` )))
LEFT JOIN `contatti_tlk_statointeresse` `si ON(( `i`.`stato_interesse` = `si`.`id_statointeresse` )))
LEFT JOIN `v_anagrafica_utenti` `ar` ON(( `i`.`id_referente` = `ar`.`id` )))
WHERE ( `a`.`id` > 0 )
GROUP BY `i`.`id_interesse`
UNION
SELECT CASE
WHEN EXISTS (SELECT *
FROM `contatti_t_interazioni` `iz`
WHERE `iz`.`id_interesse` = `i`.`id_interesse`) THEN "si"
ELSE "no"
end AS `Interazioni`
FROM ((((`contatti_t_interessi` `i`
LEFT JOIN `contatti_t_proposte` `p` ON(( `i`.`id_interesse` = `p`.`id_interesse` )))
LEFT JOIN `contatti_t_esteri` `ce` ON(( `i`.`id_contattoestero` = `ce`.`id_contattoestero` )))
LEFT JOIN `contatti_tlk_statointeresse` `si` ON(( `i`.`stato_interesse` = `si`.`id_statointeresse` )))
LEFT JOIN `v_anagrafica_utenti` `ar` ON(( `i`.`id_referente` = `ar`.`id` )))
WHERE ( `ce`.`id_contattoestero` > 0 )
GROUP BY `i`.`id_interesse`;
当我尝试执行该查询时,它不会显示任何错误,但查询执行永远不会结束。
出什么问题了?我之所以使用联合,是因为由于查询时间过长,我隐藏了其他选择属性。
对不起,我的英语,希望您能理解我的要求。
谢谢