I'm having a problem when dealing with two tables, tb_adm_anuncios
and tb_adm_anuncio_banner
.
For each ad I have 4 banners, and to list those ads I need:
**Anúncio:**
-Nome do Anúncio
-Link
**Banner:**
-Imagem
The command I am using to do this is this:
SELECT
anuncios.id AS id_anuncio,
anuncios.titulo_anuncio,
banners.id AS id_banner,
Rand(banners.imagem) AS imagem_banner
FROM tb_adm_anuncio AS anuncios
LEFT JOIN tb_adm_anuncio_banner AS banners ON anuncios.id = banners.fk_anuncio AND
anuncios.status = 1
GROUP BY banners.fk_anuncio
limit 12
When I run this command it does not return all my ads, and I do not know why.