Forum Moderators: open
The problem is, with ORDER BY on the answer timestamp field, because I am selecting by a specific user ID, it only knows the timestamp of the answers provided by that user. I want to sort it on the latest answer first, but an answer by anyone, not just the specific USERID I supply to the query.
Any ideas? Here is the code I have currently:
SELECT DISTINCT q.*, a.answer
FROM questions q, answers a
WHERE a.qid = q.id
AND a.uid = [$USERID]
ORDER BY a.tstamp DESC"
For the record, I then manipulate the output to display the question and the latest answer only. At the moment I can get it to show the question and the latest answer from my user, but not necessarily the latest answer period.
Many thanks,
Ian
You'll need some further processing to filter out any duplicates (e.g., if a person posted an answer to his own question) and sort correctly.