By jmather on
I noticed that when using sorting in views with a nodequeue relationship, if I set the sort as nodequeue asc, and I'm pulling other nodes using views_or, the query will result in the nodes always displaying above the nodes in the nodequeue. This appears to happen because sorting on the nodequeue_nodes_node_position will be null for the other nodes (thus they show up first):
SELECT node.nid AS nid, nodequeue_nodes_node.position AS nodequeue_nodes_node_position, node.created AS node_created FROM node node LEFT JOIN nodequeue_nodes nodequeue_nodes_node ON node.nid = nodequeue_nodes_node.nid AND nodequeue_nodes_node.qid = 11 LEFT JOIN term_node term_node ON node.vid = term_node.vid WHERE node.type in ('article') AND ((nodequeue_nodes_node.nid <> 0) OR ((term_node.tid = 15) AND (term_node.vid IS NOT NULL))) ORDER BY nodequeue_nodes_node_position ASC;
Results:
+-----+-------------------------------+--------------+
| nid | nodequeue_nodes_node_position | node_created |
+-----+-------------------------------+--------------+
| 97 | NULL | 1254268453 |
| 65 | 1 | 1251312960 |
| 66 | 2 | 1251313021 |
| 67 | 3 | 1251313067 |
+-----+-------------------------------+--------------+
I seem to be able to fiddle with this and do an order by date posted like so:
SELECT node.nid AS nid, nodequeue_nodes_node.position AS nodequeue_nodes_node_position, node.created AS node_created FROM node node LEFT JOIN nodequeue_nodes nodequeue_nodes_node ON node.nid = nodequeue_nodes_node.nid AND nodequeue_nodes_node.qid = 11 LEFT JOIN term_node term_node ON node.vid = term_node.vid WHERE node.type in ('article') AND ((nodequeue_nodes_node.nid <> 0) OR ((term_node.tid = 15) AND (term_node.vid IS NOT NULL))) ORDER BY node_created ASC, nodequeue_nodes_node_position DESC;
and get the results, but that doesn't really give me a good answer.
Is there a way to get the nodequeue results first then the other nodes?