[thelist] SQL trouble
Anthony Baratta
anthony at baratta.com
Wed Nov 16 15:47:41 CST 2011
Here's one possible solution (Rudy might slap me down):
(This assumes you are using auto-increment for the id - the largest id
for a batch is always the current history.)
select all current status...
select batches.id, batches.uniq, max(history.id) from batches
join history on batches.id = history.id
group by batches.id, batches.uniq
select all status of 3...
select batches.id, batches.uniq, max(history.id) from batches
join history on batches.id = history.id
where history.status = 3
group by batches.id, batches.uniq
--
Anthony Baratta
"I used to think the brain was the most
important part of my body, until I realized
what was telling me that." - Emo Phillips
More information about the thelist
mailing list