4 messages in com.mysql.lists.win32Need SQL Help Finding Current Status ...
FromSent OnAttachments
Michael Avila15 Dec 2005 19:12 
SGr...@unimin.com15 Dec 2005 22:12 
Michael Avila16 Dec 2005 05:55 
SGr...@unimin.com16 Dec 2005 07:30 
Subject:Need SQL Help Finding Current Status of members
From:Michael Avila (Mich@sbcglobal.net)
Date:12/15/2005 07:12:01 PM
List:com.mysql.lists.win32

I have a table which keeps track of the status of members. In the table is

member_id int(8) status_code char(1) status_date date

KEY member_id (member_id,status_code,status_date)

Each member can have multiple records because a record is added each time the status changes but the old record is kept for history.

What I want to do is find the latest status for each member. Actually I want to find all those with an status of "A". But it must be the current (latest) status. How do I find the most current date for each member in a pile of many records for many members with many status settings with one SQL statement? This is a bit beyond my capabilities so I am asking for help.

My initial SQL is

SELECT * FROM memberstatus WHERE status_code = 'a'

but that is my limit. I know an AND comes next but need help after that! I know that MAX is not for dates so that is out. Is there a LATEST DATE? I did not see one when I was looking at the date functions.

Appreciate the help.

Mike