【问题标题】:Exclude three ID's from MySQL query从 MySQL 查询中排除三个 ID
【发布时间】:2021-06-19 13:52:54
【问题描述】:

谁能帮忙解答这个问题?

我在下面有这个默认查询,需要从结果中排除 3 个 ID(5707、5782、5755),我无法猜测在这个查询结构中添加 NOT IN。请帮忙!

        $agents_query = array(
            'post_type'      => 'agent',
            'posts_per_page' => $number_of_posts,
            'paged'          => $paged,
            'orderby'        => 'rand',
        );

        $agents_query        = inspiry_agents_sort_args( $agents_query );
        $agent_listing_query = new WP_Query( $agents_query );

【问题讨论】:

标签: mysql wordpress


【解决方案1】:

解决方案:

        $agents_query = array(
            'post_type'      => 'agent',
            'post__not_in'   => array(5707,5782,5755),
            'posts_per_page' => $number_of_posts,
            'paged'          => $paged,
            'orderby'        => 'rand',
        );

        $agents_query        = inspiry_agents_sort_args( $agents_query );
        $agent_listing_query = new WP_Query( $agents_query );

【讨论】:

    猜你喜欢
    • 2014-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-15
    • 1970-01-01
    • 2013-11-21
    • 2017-12-23
    • 1970-01-01
    相关资源
    最近更新 更多