My tables:
agencias (id, nome_agencia, ads -> FK pra tabela de baixo)
ads (id, nome, agencia -> essa é FK pra tabela anterior)
The problem is this: each agency will have ads no ads have a lead agency
I want to make a select displaying agencia_id, agency_name, ads_id, ads_agency_name
I tried that, but I do not know how to "fit" the agency name.
SELECT agencias.id as id_agencia, agencias.nome as agencia_nome, ads.id as id_ads, ads.agencia as ads_agencia_id
FROM agencias
INNER JOIN ads
ON agencias.id=ads.agencia