I'm trying to write the SQL statement to select all nodes of a specific type and order them by the sum vote and date created. This works but limits only to nodes that have been voted on...

SELECT node.nid, node.title, votingapi_cache.value 
FROM node 
INNER JOIN votingapi_cache ON votingapi_cache.content_id = node.nid 
WHERE node.type = 'image' 
AND node.status = 1 
AND votingapi_cache.function = 'sum' 
ORDER BY votingapi_cache.value DESC, node.created DESC

What do I have to do to get the nodes that have not been voted on too? Thanks in advance.

Comments

geohelper’s picture

AND (votingapi_cache.function = 'sum' OR votingapi_cache.content_id = NULL)