Hopefully someone can help me out with this, it's driving me nuts...
I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data pertaining to each event in table1. So for each record in Table1 there could be hundreds of records pertaining to that record in Table2 - I am trying to count those records (to reveal the number of people registered for the event held in table1)
I am trying to construct an SQL query which will select ALL events from table1, and COUNT the number of records/registrants pertaining to each event returned in the first select statement.
I know it is possible, and easier, to create a recordset for Table1 and then count the records from table2 each time you loop through the first recordset - but the problem is the two tables have over 340 columns in each (Yeah, I know.. it's mad.. I didn't do it!), so opening and closing a recordset for each loop through table1 is out of the question. We're actually currently doing that and the page takes forever to load (about 1 second per record, so if you have 300 events.. you're waiting about 5 minutes each time you load this page) - thusly I am trying to speed it up by selecting all the events from table1, and counting the registrations for that event in a single select statement.. so that there is no need to continually open and close a recordset for each loop through Table1 records.
I'm sure a subquery of some sort is in order here, but can't get it right, tried a million things.. and notta!
Hope someone can help!
Sincerely,
Mark
I have two tables - We'll call them table1 and table2. Table1 holds event information, and table2 holds user registration data pertaining to each event in table1. So for each record in Table1 there could be hundreds of records pertaining to that record in Table2 - I am trying to count those records (to reveal the number of people registered for the event held in table1)
I am trying to construct an SQL query which will select ALL events from table1, and COUNT the number of records/registrants pertaining to each event returned in the first select statement.
I know it is possible, and easier, to create a recordset for Table1 and then count the records from table2 each time you loop through the first recordset - but the problem is the two tables have over 340 columns in each (Yeah, I know.. it's mad.. I didn't do it!), so opening and closing a recordset for each loop through table1 is out of the question. We're actually currently doing that and the page takes forever to load (about 1 second per record, so if you have 300 events.. you're waiting about 5 minutes each time you load this page) - thusly I am trying to speed it up by selecting all the events from table1, and counting the registrations for that event in a single select statement.. so that there is no need to continually open and close a recordset for each loop through Table1 records.
I'm sure a subquery of some sort is in order here, but can't get it right, tried a million things.. and notta!
Hope someone can help!
Sincerely,
Mark
Comment