Skip to content
Advertisement

check if select count value is null/empty query builder symfony

My query builder looks like this

 $qb
            ->select([
                'c.id as c_id',
                'c.name as c_name',
                sprintf('(SELECT COUNT(t) FROM %s t WHERE t.example = c.example) as t_total',
                    t::class),
                sprintf('(SELECT COUNT(z) FROM %s z WHERE z.example = c.secondExample) as z_total',
                    z::class),
            ])
            ->from(c:class, 'c')
            ->getQuery()->getResult();

is there any way to check that t_total and z_total is null? I don’t want show this row only if t_total AND z_total is null/empty

Advertisement

Answer

as @mickmackusa say

$qb->having('z_total IS NOT NULL OR t_total IN NOT NULL');

works the way i wanted

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement