Can someone show me the code to find the total count of records in (table2) that belong to a record in (table1) based on the same id?<BR>thanks!
SELECT t1.id, (SELECT COUNT(*) FROM Table2 WHERE id = t1.id) as CountFromOtherTable<BR>FROM Table1 T1<BR><BR>This returns all Id's in table1 and the corresponding count in table2
Maybe i should give more details. I am displaying all the customers in a table by looping through the table but I want to show the number of orders each of those customers have placed (which is in another table.) in the same list of customers.
select count(*) from table2<BR>where table2_id = table1_id
just join the two tables with the corresponding id's and select the needed fields. Display those needed fields inside the looping of the recorset!!