0
Friends need a Select that loads: (all portals linked to a user and an additional column informing which portals were selected in a given news)
So far my SQL is like this...:
select
distinct
case when usudesc.txt_nome is null then 0 else 1 end as MeusPortais,
case when nopo.id_noticia is null then 0 else 1 end as PotalSelecionado,
porti.id_portal, nopo.id_noticia, porti.txt_apelido
from tb_portal porti
left join tb_noticiasportais nopo on nopo.id_portal = porti.id_portal
and nopo.id_noticia = '26'
left join tb_usuarioportal usu on usu.id_portal = porti.id_portal
and usu.id_usuario = '1'
left join tb_usuario usudesc on usudesc.id_usuario = usu.id_usuario
left join tb_noticias noti on noti.id_noticia = nopo.id_noticia
order by porti.txt_apelido asc
The base has this structure:
tb_noticias(id_noticia, txt_titulo)
tb_noticiasportais (id_noticia, id_portal)
tb_portal (id_portal, txt_titulo)
tb_user portal(id_usuario, id_portal)
tb_usuario(id_usuario, txt_usuario)
Friend... it’s not quite that. But it gave me a line of reasoning:
– Fellipe J. de Sousa