0

Order your nodes by most recent post OR comment date

Posted July 2nd, 2010 in , by thomas

Hello,

ever wanted to sort your nodes by post or comment date like forums do ( last “action” first) ?

you can do that easily with mysql and greatest select

SELECT n.nid, title,
GREATEST(n.created, last_comment_timestamp) as dateup
 
FROM node n
INNER JOIN `node_comment_statistics` using(nid)
 
order by dateup desc

Leave a Reply