I am trying to run a query where all messages are pulled form a users inbox. Messages are kept clean in the inbox by setting a 'mail_orig' column in the table to the date of the original message.. this way all correspondences between the two parties concerning this message can easily be displayed on the same page. What I'm trying to do in this query however is pull the LAST message sent for each DISTINCT MAIL_ORIG (yes, I've tried this using the DISTINCT function for SQL as well with the same kind of results) value and ORDER THEM by the MAIL_DATE column, or the date of the latest message. What's happening though is the system is using the date of the FIRST message for each correspondance and ordering them that way. Any ideas?
<cfquery name="get" datasource="ds">
SELECT *
FROM user_mail
GROUP BY mail_orig
WHERE user_id = 1
ORDER BY mail_id DESC
LIMIT #start#, 10
</cfquery>
<cfquery name="get" datasource="ds">
SELECT *
FROM user_mail
GROUP BY mail_orig
WHERE user_id = 1
ORDER BY mail_id DESC
LIMIT #start#, 10
</cfquery>