This work fine
$grid->select_command = "
SELECT DISTINCT a.id,
a.nome,
a.actividade,
(SELECT COUNT(*) FROM antp_pub_empresas_contactos b WHERE b.empresa_id = a.id) n_contactos
FROM
antp_pub_empresas a
WHERE a.id > 0
AND a.id NOT IN (SELECT c.empresa_id FROM antp_pub_empresas_conversacoes c WHERE c.pessoa_antp = 43)";
But this does not
$flt = " AND a.id NOT IN (SELECT c.empresa_id FROM antp_pub_empresas_conversacoes c WHERE c.pessoa_antp = 43) ";
$grid->select_command = "
SELECT DISTINCT a.id,
a.nome,
a.actividade,
(SELECT COUNT(*) FROM antp_pub_empresas_contactos b WHERE b.empresa_id = a.id) n_contactos
FROM
antp_pub_empresas a
WHERE a.id > 0 $flt";
WHY???
1 Answers
Your Answer