0
我有一个查询返回与给定criteia匹配的数据库表中的所有帖子,但我正在寻找一种方法,最多只能返回5个帖子每个'post_type'
。目前查询是选择每一个匹配的文章,我不得不限制每个'post_type'
在PHP中的数字,这不是特别有效。在数据库表中返回每个'post_type'的最多5个
可以这样做吗?谢谢。
SELECT ID, post_title, post_type
FROM wp_posts
WHERE 1=1
AND post_status = "publish"
AND (
post_type IN (
"staff"
)
AND post_name LIKE "%The%"
)
OR (
post_type NOT IN (
"staff",
"Attachment"
)
AND (
post_name LIKE "%The%"
OR post_title LIKE "%The%"
)
)
ORDER BY post_type, post_name ASC
?最近的五个?最早的五个?你可以请张贴你的模式吗? – 2012-07-17 10:06:17