SELECT DISTINCT nid sticky created vc value FROM node votingapi_cache

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
SELECT DISTINCT n.nid, n.sticky, n.created, vc.value
FROM {node} n , {votingapi_cache} vc , {users_roles} ur , {recomended} re
WHERE n.promote = 1 AND n.status = 1
AND (n.type = 'story' OR n.type = 'page' OR n.type = 'poll')
AND (
(vc.content_id = n.nid AND vc.value >= 3 AND vc.function = 'sum')
OR (ur.uid = n.uid AND ur.rid IN (3, 4))
OR n.uid = 1 OR re.content_id = n.nid
)
GROUP BY n.nid ORDER BY n.sticky DESC, n.created DESC