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 6707509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:38:53+00:00 2026-05-26T07:38:53+00:00

The problem I’m running a query using Workbench 5.2.35 and a MySQL server 5.5

  • 0

The problem

I’m running a query using Workbench 5.2.35 and a MySQL server 5.5 and I have the error “Error Code: 2013. Lost connection to MySQL server during query” after 600.516 seconds also after little changes in the query. The query has two roles:

  1. select a particular type of records characterised by having ‘value1’ in ‘col1’ (pass from Stage A to Stage B)
  2. remove the records where the value in ‘col2’ is the same as the value in ‘col2’ of the next result (pass from Stage B to Stage C)

    Stage A             Stage B             Stage C
    ***************     ***************     ***************
    *ID *col1*col2*     *ID *col1*col2*     *ID *col1*col2*
    ***************     ***************     ***************
    *1  * A  * a  *     *3  * C  * a  *     *3  * C  * a  *
    *2  * B  * a  *     *7  * C  * f  *     *7  * C  * f  *
    *3  * C  * a  *     *8  * C  * f  *     *16 * C  * b  *
    *4  * S  * a  *     *9  * C  * f  *     *18 * C  * c  *
    *5  * B  * a  *     *16 * C  * b  *
    *6  * A  * g  *     *17 * C  * b  *
    *7  * C  * f  *     *18 * C  * c  *
    *8  * C  * f  *
    *9  * C  * f  *
    *10 * A  * f  *
    *11 * B  * f  *
    *12 * D  * f  *
    *13 * S  * f  *
    *14 * F  * f  *
    *15 * F  * f  *
    *16 * C  * b  *
    *17 * C  * b  *
    *18 * C  * c  *
    

and is a generalisation of:
MySQL, select rows where a parameter value depends on the value that it has in a different row

The query is:

SELECT t.id, t.col2, t.col3, t.col4, t.col5 FROM tablename t
WHERE t.id < 1000000
    AND t.col1 = 'value1' 
    AND t.col2 <> 
    (SELECT col2 FROM tablename
        WHERE col1 = 'value1' 
        AND id > t.id 
        LIMIT 1);

Reason for the error

Now, from this post
https://serverfault.com/questions/29597/what-does-mysql-error-2013-mean
the causes of this error can be:

  1. Someone KILLed the query
  2. Network problems caused the connection to die
  3. The server crashed/died
  4. Your connection was idle for wait_timeout and was killed
  5. The client wasn’t pulling data fast enough for net_wait_timeout and was killed

but since the query stops at 600.516 seconds, I guess that the problem in this case is number 4 (timeout).

Possible problems and solutions

The first idea would be to increase the wait_timeout time, but I think that this is triggered by a previous error: the query doesn’t return anything but continues to run. The limit t.id < 1000000 is used exactly to test the query in a reasonably limited subset (the database has about 200 millions of entries)
So, I’m thinking that there is some problem in the query, in particular in the passage between Stage B and Stage C (the previous step is trivial)

Any idea for the error or for the query will be much appreciated.

Thanks


The solution

this is the working code, inspired by the best answer. The command DISTINCT work, but finally I used GROUP BY and ORDER BY in order to present the results in a better way.

SELECT id, col1, col2, ..., coln FROM tablename
    WHERE col1 = 'value1' 
    AND col2 = 'value2'
    ... 
    AND coln = 'valuen'
    GROUP BY col2
    ORDER BY id;
  • 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-05-26T07:38:54+00:00Added an answer on May 26, 2026 at 7:38 am

    SELECT DISTINCT Par FROM table_name

    http://www.w3schools.com/sql/sql_distinct.asp

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem solved: Thanks guys, see my answer below. I have a website running in
Problem: I am using Java Tutorials™ sourcecode for this. This is the source code.
Problem: I'm attempting to disable a radio button by using the code below. This
Problem I have a Silverlight 5 application using the treeview from the SDK. Now
Problem is that application closes without any error, VS stays opened. I have multiple
Problem: I have an address field from an Access database which has been converted
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem I have timestamped data, which I need to search based on the timestamp
Problem: We have a web app that calls some web services asynchronously (from the
Problem 1 Error: Microsoft JScript runtime error: '$.fn' is null or not an object

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.