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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:48:48+00:00 2026-06-07T05:48:48+00:00

So I have a MySQL table that looks something like this: id timestamp action

  • 0

So I have a MySQL table that looks something like this:

id        timestamp                action        timePassed

1         2012-07-10 22:44:00      start         0
2         2012-07-10 22:44:50      pause         50
3         2012-07-10 22:45:30      play          50
4         2012-07-10 22:47:25      pause         205
5         2012-07-10 22:48:05      play          205

I don’t know how obvious it is but what’s happening here is basically on every ‘pause’ row I am calculating the difference in seconds between the current timestamp and the timestamp of the ‘start’ row.

The only way I can think of doing this is to INSERT a new ‘pause’ row into the database so the timestamp is generated…then query the database for the timestamp of that ‘pause’ row…calculate the difference in seconds between that ‘pause’ row and the ‘start’ row using PHP…then UPDATE the ‘pause’ row with the timePassed result.

My question is whether or not there is a better way to do this (i.e. using timediff or some other MySQL command). The issue is the ‘pause’ timestamp doesn’t exist until I make the INSERT, so I feel like that needs to happen first before I can make any calculation?

  • 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-07T05:48:49+00:00Added an answer on June 7, 2026 at 5:48 am

    Well if your table is like this and your requirement is like this then you are on track..

    However better if you check the second difference between last row and last to last row. This will give you idea for how many second user has PAUSED or Played the TRACK.

    INSERT INTO table (timestamp, action, timePassed)
        SELECT now(), 'pause', SECOND(timediff(now(), timestamp))
        FROM table
        WHERE ID = (Select Max(ID) from Table)
    

    Put action as you like so you can insert time difference between two.

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

Sidebar

Related Questions

I have a MySQL table that looks something like this: |---ID---|---COUNTER---| | 1 |
I have a MySQL table that looks something like this: +--------------------------------------+ | id |
I have a mysql table that looks something like this: Row 1: 'visitor_input_id' =>
I have a MySQL table that looks something like this: +-----+------------+ | id |
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a MySQL table that looks like this: `id` int(10) unsigned NOT NULL
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
I have one table that looks something like this: id parent_id name 1 0
I have a simple MySQL query that looks something like this SELECT * FROM
I have a table in MySQL That looks like the following: date |storenum |views

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.