I found what was missing.

I put distinct into the 'count( )' tag then it resolve the problem.

Tkz for all

Joao Pedro

----- Original Message ----- 
From: "Joao Pedro" <[EMAIL PROTECTED]>
To: "Joao Pedro" <[EMAIL PROTECTED]>
Sent: Thursday, January 08, 2004 8:24 AM
Subject: Consultation in 4 tables


> Hi People,
>
> forgive me for the previous message,
> the tables had left badly located and are redispatching with corrected
them.
>
> I have a 4 tables where de relationship are:
>
> *=Primary Key
>
>  TABLE_A            TABLE_B
>   name                     code_B
>  *code_A ====== code_A
>
> TABLE_B            TABLE_C
>   name                      code_C
> *code_B ======= code_B
>
> TABLE_B            TABLE_D
>   name                     code_D
> *code_B ======= code_B
>   code_A
>
> I need a query where I have the a amount that a code of the Table A
appeared
> in Table B and the number of code of Table B that they had appeared in
Table
> C and Table D. I made this query:
>
> "Select TABLE_A.*, count(TABLE_B.code_B), count(TABLE_C.code_C) from
TABLE_A
> left join TABLE_B on TABLE_B.code_A=TABLE_A.code_A left join TABLE_C on
> TABLE_C.code_B = TABLE_B.code_B left join TABLE_D on TABLE_D.code_B =
> TABLE_B.code_B group by TABLE_A.code_A".
>
> The reply it comes multiplied for the number of times that appear in
tables
> B, C and D. Therefore if it has 1 register in B, 2 in C and 3 in D. Then
it
> appears 6 as reply in each item, being that it would have to appear 1, 2
and
> 3 respectively.
>
> I am thankful very if somebody will be able to help me?
>
> Best Regards,
> Joao Pedro
>
>
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to