We help IT Professionals succeed at work.
Get Started

Filtering data for last date, getting all columns.

KurtVon asked
Last Modified: 2013-11-05
I'm storing grid data in a database, but "journaling" each cell to allow retrieving the grid state at a particular time.  The initial storage uses the columns name, date, row, col, value.

To change a cell value I just insert a row with the row, col, and value set and date set to NOW().  To delete, value is set to NULL.

But to get the current cell data is proving too difficult.  I know I want to do something like:

SELECT row, col, value FROM journal WHERE name = ? GROUP BY row, col HAVING date = MAX(date)

but of course this won't work since the value column is not part of the GROUP BY.

I could get a value based on the date, but need to use the row and col values as well, and each row and column may have a different MAX(date).

I can't be the first person to try journaling data in MySQL, so a solution to the query or a pointer to teh right way to do this would be accepted.

Thanks for any help.
Watch Question
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE