I'm having a problem similar to one I mentioned last week.  I'm trying
to retrieve the number of posts a selected user has made on a selected
forum, plus details of the record of his/her latest post (date and
subject).

SELECT COUNT(*) AS postcount, m.user_id, m.subject, m.posting_date,
u.username, u.registered
FROM messages m, users u
WHERE m.forum_id = '297' AND m.user_id = '4910' AND m.user_id =
u.user_id
GROUP BY m.user_id ORDER BY m.posting_date DESC

Basically this statement ignores anything to do with the ordering, and
brings out a post (seemingly at random) which is not the latest (i.e.
I'm hoping and expecting for 30th July, but get a record from 19th May).
If I use "MAX(m.posting_date)" I can retrieve the latest date, but any
other data from the 'message' fields (i.e. the subject) relates to this
record from 19th May.

Is there a way of getting the count and this latest record in the one
statement.

Any help, as always, would be much appreciated.

Gary


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to