Ireneusz Piasecki wrote:
>
> Hi my friends !!
>
> Some few days i have problems with count().
> i have 3 tables:
>
> t1 holds:
> +----+--------+
> | id | number |
> +----+--------+
> | 1 | one |
> | 2 | two |
> | 3 | three |
> | 4 | four |
> | 5 | five |
> | 6 | sixs |
> +----+--------+
>
> t2 holds:
>
> +----+-------+---------------------+
> | id | id_t1 | t |
> +----+-------+---------------------+
> | 1 | 1 | 2001-07-03 15:03:34 |
> | 2 | 1 | 2001-07-03 15:03:34 |
> | 3 | 1 | 2001-07-03 15:03:34 |
> | 4 | 2 | 2001-07-03 15:03:34 |
> | 5 | 3 | 2001-07-04 12:00:00 |
> | 6 | 3 | 2001-07-04 12:00:00 |
> | 7 | 4 | 2001-07-04 13:11:00 |
> +----+-------+---------------------+
>
> t3 have it:
> +----+-------+---------------------+
> | id | id_t1 | t |
> +----+-------+---------------------+
> | 1 | 1 | 2001-07-04 13:11:00 |
> | 2 | 2 | 2001-07-04 13:11:00 |
> | 3 | 3 | 2001-07-04 13:11:00 |
> | 4 | 1 | 2001-07-04 13:11:00 |
> | 5 | 4 | 2001-07-04 13:11:00 |
> | 6 | 4 | 2001-07-04 13:11:00 |
> | 7 | 4 | 2001-07-04 13:11:00 |
> +----+------+----------------------+
>
> so, my target is: how many rows there are in table t2 and t3 coresponding to t1.
> Column id_t1 in t2 and t3 are values that are present in t1.id. It is important, it
>must be one query to database.
>
> I make this query:
>
> select t1.id,number,count(t2.id_t1),count(t3.id_t1) from t1
> left join t2 on t2.id_t1=t1.id
> left join t3 on t3.id_t1=t1.id
> group by number order by number desc
Hello,
I don't know what exactly you want to count, but one thing seems to be
obviously to me: You can't make a left join between t2 and t3 on
t3.id_t1=t1.id (line 3 of the query).
Pozdrowienia do Polski,
Robert Vetter
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php