This topic is locked

SQL with several details

4/3/2012 7:13:16 AM
PHPRunner General questions
I
imendes author

I have a master table with 2 detail tables.
My problem is how can I show that?
I have:
SELECT

clipping.DATA,

clipping.SEMANA,

clipping.TRIMESTRE,

clipping.TITULO,

clipping.TENDENCIA,

clipping.COMENTARIOS,

clipping.CHAVE,

instituicoes.NOME,

provincias.NOME AS NOME1

FROM clipping

INNER JOIN clip_instituicoes ON clipping.CHAVE = clip_instituicoes.ID_CLIPPING

INNER JOIN instituicoes ON clip_instituicoes.ID_INSTITUICAO = instituicoes.CHAVE

INNER JOIN clip_provincias ON clipping.CHAVE = clip_provincias.ID_CLIPPING

INNER JOIN provincias ON clip_provincias.ID_PROVINCIA = provincias.CHAVE

ORDER BY clipping.CHAVE
As each detail have 2 records, I get 12 rows (I have 3 master records) (I put only 3 fields here):

CHAVE / NOME / NOME1

18 TIMIN Bengo

18 TIMIN Cabinda

18 EMS Bengo

18 EMS Cabinda

20 TIMIN Benguela

20 TIMIN Cabinda

20 EMS Benguela

20 EMS Cabinda

22 TIMIN Bié

22 TIMIN Cabinda

22 EMS Bié

22 EMS Cabinda
There is a better way to do that? I want to produce a report, so I can export to excel.
Thank you.