Select in three tables in a list - MYSQL

1

I have three tables:

ESCRITORIOS
id
nome

ESCRITORIOS_SEGMENTO
id_escritorio
id_segmento

SEGMENTOS
id
nome_segmento

What I need is to give a SELECT to list this information as well

SEGMENT BLABLA:

desk 1, desktop 2

BLIBLI SEGMENT

Desk 1, Desk 4

BLOB SEGMENT

2, desk 3

BLUBLU SEGMENT

desktop 3

I tried in many ways, with LEFT JOIN, GROUP, but it did not roll ....

    
asked by anonymous 22.02.2016 / 17:57

1 answer

1

I did it!

SELECT *, associados.caminho AS caminho_associado, area.caminho AS caminho_area, area.id AS id_area FROM area LEFT JOIN associados_area ON associados_area.idarea = area.id LEFT JOIN associados ON associados.id = associados_area.idassociado WHERE associados.ativo = "1"    ORDER BY area.nome_pt ASC
    
22.02.2016 / 18:03