我的查询:
SELECT a.id, a.title, a.introtext, a.fulltext, a.created, a.image, a.catid, a.sectionid
FROM jos_content AS a
LEFT JOIN jos_categories AS c
ON a.catid = c.id
WHERE a.state = 1
AND c.published = 1
AND ( publish_up = "0000-00-00 00:00:00" OR publish_up <= "2012-02-08 11:10:25" )
AND ( publish_down = "0000-00-00 00:00:00" OR publish_down >= "2012-02-08 11:10:25" )
AND a.access <= 0
AND a.catid = 41
ORDER BY a.created DESC, a.id DESC
LIMIT 0, 1
对于30个类别,我在MySQL中有30个请求(更改AND a.catid = 21,AND a.catid = 42及以上)。
如何对所有类别(21,41,42)进行分组,并从jos_content中选择最后添加的内容
答案 0 :(得分:0)
类别是否分配到同一部分? 如果是,只需选择sectionid而不是catid。