SELECT
immobili.*,
categoria.ref AS categoriaRef,
categoria.nome AS categoriaNome,
fornitore.ragsoc AS fornitoreNome,
cliente.nome AS clienteNome,
cliente.cell AS clienteCell,
cliente.mail AS clienteMail,
be_status.nome AS statusLabel,
be_status.classe AS statusClass,
be_status.deliver AS delivered,
be_status.progress AS progress,
localita.nome AS localita_label,
tipologia.main AS tipo_main,
tipologia.tipo AS tipo_label
FROM immobili
LEFT JOIN categoria ON (immobili.id_cat = categoria.id)
LEFT JOIN fornitore ON (immobili.id_fornitore = fornitore.id)
LEFT JOIN cliente ON (immobili.id_cliente = cliente.id)
LEFT JOIN be_status ON (immobili.id_status = be_status.id)
LEFT JOIN bk_localita AS localita ON (immobili.id_localita = localita.id)
LEFT JOIN immobili_tipo AS tipologia ON (immobili.tipologia = tipologia.id)
WHERE
immobili.active = 1 AND tipologia.active = 1 GROUP BY immobili.id ORDER BY data DESC LIMIT 20