I'm new to mysql and I was wondering if I could trouble some of you for
help. I have a table in my database that may contain multiple versions
of the same element as different rows.
I wanted to use the following query to group the rows by element with
"group by" and then use the "having" to get the most recent version of
each element, which would then be returned in "select" but this doesn't
seem to be working. Any elements with multiple versions are simply not
returned.
I could swear that I have used a similar approach in the distant past
with other databases and it worked, though, so I must be bollocksing
this up pretty badly while attempting to work off of what I
remember...in any case, any help on understanding why this isn't
working would be appreciated.
select
element_id -- not unique!
,created_on
,name
,description
from
elementversions
group by
element_id
having
created_on = max(created_on)