我有一个查询,它返回一个数据库表中与给定条件匹配的所有帖子,但我正在寻找一种方法,可以从每个'post_type'
. 目前,查询正在选择每个匹配的帖子,我不得不限制'post_type'
PHP 中每个帖子的数量,这不是特别有效。
这可以做到吗?谢谢。
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