Select from three tables in a list - MYSQL

Asked

Viewed 80 times

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 like this

BLAH SEGMENT:

clerk 1, office 2

BLIBLI SEGMENT

clerk 1, office 4

BLOBLOBLO SEGMENT

clerk 2, office 3

BLUBLU SEGMENT

office 3

I tried several ways, with LEFT JOIN, GROUP, but did not roll....

1 answer

1


I got!

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.