HI guys !

I have some problem. Let's go !
I have 3 tables. Fields are describe below:

1) table1
  | id (int 3) | comment (text) | t (timestamp 14) |

  she holds:
  | 1 | there is my comment1 | 200010606123456 |
  | 2 | there is my comment2 | 200010606123456 |
  | 3 | there is my comment3 | 200010606123456 |
  | 4 | there is my comment4 | 200010606123456 |


2) table2
  | id (int 3) | id_tab1 (int 3) | img_path (varchar 10) | t (timestamp 14) |

  she holds:  
  | 1 | 1 | /tmp/1.jpg   | 200010606123456 |
  | 2 | 1 | /tmp/12jpg  | 200010606123456 |
  | 3 | 1 | /tmp/21.jpg | 200010606123456 |
  | 4 | 2 | /tmp/4.jpg   | 200010606123456 |
  | 5 | 2 | /tmp/45.jpg | 200010606123456 |
  | 6 | 3 | /tmp/6.jpg   | 200010606123456 |
  | 7 | 3 | /tmp/7.jpg   | 200010606123456 |


3) table3
  | id (int 3) | id_tab1 (int 3) | story (text) | t (timestamp 14) |
  
 she holds:

  | 1 | 1 |  ble ble ble   | 200010606123456 |
  | 2 | 1 | ble ble ble    | 200010606123456 |
  | 3 | 1 |  ble ble ble   | 200010606123456 |
  | 4 | 1 | ble ble ble    | 200010606123456 |
  | 5 | 2 |  ble ble ble   | 200010606123456 |
  | 6 | 3 |  ble ble ble   | 200010606123456 |
  | 7 | 4 |  ble ble ble   | 200010606123456 |

I would like to count, how many rows in table2 and table3 coresponding to table1

and i made this query:

select table1.id,count(table2.id_tab1),count(table3.id_tab1) from table1
left join table2 on table2.id_tab1=table1.id
left join table3 on table3.id_tab1=table1.id
group by table1.id order by table1.id;

But i wonder, the results in count columns aren't truth.  

So, what is the correct query ????

Please, any answer could you send me at email below too.

Regards.

Ireneusz Piasecki
webmaster www.b-c.pl
KomNet s.c
[EMAIL PROTECTED]
tel: 0 606 356 235
[EMAIL PROTECTED]
[EMAIL PROTECTED] 

Reply via email to