Spudhead
04-10-2007, 11:34 AM
SELECT
tblPageItems.id,
tblPageItems.item_name,
tblPageItems.item_category,
tblItemVersions.html
FROM tblPageItems
INNER JOIN tblItemVersions ON tblItemVersions.page_item_id = tblPageItems.id
If there's more than one entry in tblItemVersions with a particular Item ID - as there will be, this is for a CMS with version control - then the query above will return a row for each version of each item found.
I don't want that. I just want a row for each Item ID, containing the latest (ie: highest ID) corresponding html field from tblItemVersions. And I'm having a mental block, and can't figure it out. Anyone? :confused:
tblPageItems.id,
tblPageItems.item_name,
tblPageItems.item_category,
tblItemVersions.html
FROM tblPageItems
INNER JOIN tblItemVersions ON tblItemVersions.page_item_id = tblPageItems.id
If there's more than one entry in tblItemVersions with a particular Item ID - as there will be, this is for a CMS with version control - then the query above will return a row for each version of each item found.
I don't want that. I just want a row for each Item ID, containing the latest (ie: highest ID) corresponding html field from tblItemVersions. And I'm having a mental block, and can't figure it out. Anyone? :confused: