Herve
|
Posted: 10/08/2003, 12:43 AM |
|
Hi,
I created a grid with a selection of fields.
For each line output of this selection, I would like to make another query to display a number of entries from another table with a criteria which will contain values coming from the first request.
EXAMPLE :
First request :
select table1.field1, table1.field2 from table1
For each line in the result, another query :
select count(*) as nb from table2 where table2.field1 = (value of table1.field1)
And the display :
1. table1.field1 | table1.field2 | nb
2. ....
3. ....
etc.
Hope it is clear ...
Any Idea ?
|
|
|
kevina
|
Posted: 10/08/2003, 12:43 PM |
|
Table orders has a status field and 'C' means the order has been processed so:
SELECT orders.orderid,customer, count( * ) FROM order_details LEFT JOIN orders ON order_details.orderid = orders.orderid WHERE orders.status = 'C' GROUP BY orderid
Displays the order id, customer and number of products per order.
|
|
|
|