Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8352839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:05:15+00:00 2026-06-09T09:05:15+00:00

I have TABLE1 as follows +———-+———-+———-+———-+———-+ + date + time + course + runner

  • 0

I have TABLE1 as follows

+----------+----------+----------+----------+----------+
+ date     + time     + course   + runner   + position +
+----------+----------+----------+----------+----------+
+ 20120701 + 1200     + london   + aaa      +   1st    +
+ 20120701 + 1200     + london   + bbb      +   2nd    +
+ 20120701 + 1200     + london   + ccc      +   3rd    +
+ 20120701 + 1300     + london   + eee      +   1st    +
+ 20120701 + 1300     + london   + fff      +   2nd    +
+ 20120701 + 1400     + new york + ggg      +   1st    +
+ 20120701 + 1400     + new york + hhh      +   2nd    +
+ 20120702 + 2000     + london   + iii      +   1st    +
+ 20120702 + 2000     + london   + aaa      +   2nd    +
+ 20120702 + 2100     + new york + iii      +   1st    +
+ 20120702 + 2100     + new york + bbb      +   2nd    +
+----------+----------+----------+----------+----------+

and a second table

+------+----------+------+--------+--------+-----+------+-------+
+idtbl2+ date     + time + course + runner + pos + link + total +
+------+----------+------+--------+--------+-----+------+-------+
+    1 + 20120701 + 1200 + london + aaa    + 1st + WWW  +       +
+    1 + 20120701 + 1200 + london + aaa    + 1st + XXX  +       +
+    1 + 20120701 + 1200 + london + aaa    + 1st + YYY  +       +
+    1 + 20120701 + 1200 + london + aaa    + 1st + XXX  +       +
+------+----------+------+--------+--------+-----+------+-------+

Basically I need to count the number of competitors (RUNNER) in a single event from TABLE1 and update that count into the TOTAL field of the second table, TABLE2.

However, TABLE1 is 8500 records in size, and TABLE2 is 65,000 records in size. When running the following query, it timesout and loses the MySQL connection.

update table2 b, table1 a set b.total = (select count(a.runner) from table1 where a.date = b.date AND a.time = b.time AND a.course = b.course AND a.position != 'DQ'  ); 

My limited understanding of JOINs leads me to believe that a JOIN will not help with the efficiency, so I am quite stuck. Any ideas out there?

@MarkByers –

The JOIN creates a temporary table, a concatenation of both table, yes? My thinking is that no matter what, I still have to compare four fields (date, time, course, runner) from one table against another.

I tried this, but it also times out:

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T09:05:17+00:00Added an answer on June 9, 2026 at 9:05 am
    1. Remove table1 from the update clause, as you are already joining the tables (internally) with the nested Select count…. You are joining table2 and table1 without a where clause, the resulting product is so big to be processed that your engine times out.

    2. Check the where clause in the nested select, I think you should filter the query by Runner, otherwise you are counting different Runners that have the same time, date, course, etc; unless that is what you want.

    update table2 b
    set b.total = (select count(a.runner) 
          from table1 
          where a.date = b.date 
          AND a.time = b.time 
          AND a.course = b.course 
          AND a.position != 'DQ'  
          AND b.runner = a.runner);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table called Table1 as follows: UserID Date 1 01/01/09 1 14/01/09
I have a table as follows > RowID SessionID EventID RequestedURL Date > 1
So if I have a table as follows with column date datetime employee varchar
If I have a query/results set as follows... from t1 in table1 join t2
I Have two datatables as follows Table1 -------------------------------- Id | Batch | Qty -----------------------------
I have a T-Sql Statement as follows; Insert into Table1 Select * From Table2
I have a Table1 with structure as follows: Database name value SYSTEM SCOTT 2
i have 2 tables, users and follows. table follows has a column named status.
I have two tables as follows: tblCountry (countryID, countryCode) tblProjectCountry(ProjectID, countryID) The tblCountry table
I have two tables as follows.. campaigns(campaignID, title) campaignMailList(campaignID, Sent) (The 2 tables are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.