Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
MySQL query
I'd like some help with SQL query, which help me to show 5 discussions with newest comments (but discussion must be DISTINCT).
Help somebody??
Help somebody??
0
This discussion has been closed.
Comments
SELECT DiscussionID, Name FROM `LUM_Discussion` ORDER BY `DateLastActive` DESC LIMIT 5
?
ugh
i don't have time to think it up now, but i'l come back to this thread later and if nobody else has done it, i'll post the answer
SELECT DISTINCT DiscussionID FROM ... LIMIT 5
however, there needs to be some php involved (or else a stored procedure in mysql) to do what i think he really wants, which is to show only discussions that the user is allowed to see. i still don't have time to look at the discussions page code, which does exactly what is needed here except returns the 30 or 50 discussions with the newest comments instead of 5.
$sql = "SELECT d.Name , c.Body, c.CommentID, c.DiscussionID FROM LUM_Comment AS c, LUM_Discussion AS d WHERE c.Deleted = '0' AND d.Active='1' AND d.DiscussionID=c.DiscussionID AND c.DateCreated >= d.DateLastActive #whispers does not touch DateLastActive AND (d.WhisperUserID=$num_util OR d.WhisperUserID!=0 AND d.AuthUserID=$num_util OR d.WhisperUserID=0 AND (c.WhisperUserID=0 OR c.WhisperUserID=$num_util OR c.AuthUserID=$num_util)) #whisper author of recipient GROUP BY d.DiscussionID ORDER BY c.DateCreated DESC LIMIT 5";
Edit: I copied/edited/pasted the request above from some code of mine. It was made to get most recent comments. It can be simplified a bit. I posted it to show the whisper stuff.