给定下面的查询,我可以得到一个结果集,其中包含查询中列出的位置 id 并按日期排序的所有新故事。我不明白的是如何重写查询,以便将每个位置 ID 限制为 1 个结果(最新)。
是否可以这样做,或者我应该在之后处理结果集?
提前致谢,
SELECT node.title AS node_title, node.nid AS nid, node.created AS node_created
FROM
{node} node
INNER JOIN {field_data_field_story_location} field_data_field_story_location
ON node.nid = field_data_field_story_location.entity_id
AND (field_data_field_story_location.entity_type = 'node'
WHERE (( (node.status = '1') AND (node.type IN ('_news_story'))
AND (field_data_field_story_location.field_story_location_tid IN
('38', '44', '46', '45', '30', '36', '37', '29', '33', '34', '28', '56', '21', '49', '32')) ))
ORDER BY node_created DESC