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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:04:32+00:00 2026-05-21T19:04:32+00:00

I have a MySQL 5.5 database with a table that looks similar to this:

  • 0

I have a MySQL 5.5 database with a table that looks similar to this:

   id test location measurement   unit device retest
    1  1       1       -2405.5     mV    1     null
    2  1       2        856        mV    1     null
    3  1       3        956.4      mV    1     null
    4  2       1       -805.5      mV    1     null
    5  2       2        1456       mV    1     null
    6  2       3        22.4       mV    1     null
    7  1       1       -805.5      mV    1     null
    8  1       2        456        mV    1     null
    9  1       3        456.4      mV    1     null
   10  2       1       -805.5      mV    1     null
   11  2       2        456        mV    1     null
   12  2       3        456.4      mV    1     null
   13  1       1       -805.5      mV    2     null
   14  1       2        856        mV    2     null
   15  1       3        756.4      mV    2     null
   16  2       1       -805.5      mV    2     null
   17  2       2        456        mV    2     null
   18  2       3        456.4      mV    2     null
   19  1       1       -805.5      mV    3     null
   20  1       2        456        mV    3     null
   21  1       3        456.4      mV    3     null
   22  2       1       -805.5      mV    3     null
   23  2       2        456        mV    3     null
   24  2       3        456.4      mV    3     null

I would like my table to reflect the number of times a device was retested:

   id test location measurement   unit device retest
    1  1       1       -2405.5     mV    1     0
    2  1       2        856        mV    1     0
    3  1       3        956.4      mV    1     0
    4  2       1       -805.5      mV    1     0
    5  2       2        1456       mV    1     0
    6  2       3        22.4       mV    1     0
    7  1       1       -805.5      mV    1     1
    8  1       2        456        mV    1     1
    9  1       3        456.4      mV    1     1
   10  2       1       -805.5      mV    1     1
   11  2       2        456        mV    1     1
   12  2       3        456.4      mV    1     l
   13  1       1       -805.5      mV    2     0
   14  1       2        856        mV    2     0
   15  1       3        756.4      mV    2     0
   16  2       1       -805.5      mV    2     0
   17  2       2        456        mV    2     0
   18  2       3        456.4      mV    2     0
   19  1       1       -805.5      mV    3     0
   20  1       2        456        mV    3     0
   21  1       3        456.4      mV    3     0
   22  2       1       -805.5      mV    3     0
   23  2       2        456        mV    3     0
   24  2       3        456.4      mV    3     0

I searched for days and all I found were techniques for counting the number of duplicates. I’m certain that the key lies in a combination of the test, location and device columns, but I lack the skills. Thank you for any assistance you would care to provide.

  • 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-21T19:04:33+00:00Added an answer on May 21, 2026 at 7:04 pm
    SELECT  *,
            EXISTS
            (
            SELECT  NULL
            FROM    mytable mr
            WHERE   mr.test = m.test
                    AND mr.location = m.location
                    AND mr.device = m.device
                    AND mr.id < m.id
            ) AS retest
    FROM    mytable m
    

    Create an index on (test, location, device, id) for this to work fast.

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

Sidebar

Related Questions

I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a MySQL database that looks similar to this: ID Group Name 1
I have a table in MySQL that looks like this: studentID subjectID anotherID anotherID2
I have a table in my MySQL database that looks like the following banner
So I have a MySQL table that looks something like this: id timestamp action
I have a MySQL database, and a particular table in that database will need
I'm trying to normalize a mysql database.... I currently have a table that contains
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
Suppose I have this database table (some sample code below) that stores the relationship

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.