phpMyAdmin
 sql >> Database >  >> Database Tools >> phpMyAdmin

Se nidificati in un select-where per un filtro dinamico condizionale

Stai cercando un join e group by ?

select f.id,
       count(*) as num_rows,
       sum(tare) as sum_tare
from history h join
     temp_fetch f
     on h.nom like concat('%', f.client, '%') or
        h.commune like concat('%', f.commune, '%')  or 
        h.type like concat('%', f.type, '%') or 
        h.mat like concat('%', f.matricule, '%') or 
        h.tare like concat('%', f.tare, '%')
where f.cancled = 0
group by f.id;