在meta_query中向左联接

问题描述

我想将posts表中的post与userMeta表中的值进行比较。然后应使用get_posts函数输出这些帖子。不幸的是,到目前为止,我还没有找到结果,但是创建了一个嵌套的SQL查询,如下所示:

function getSearchPosts( $word,$typ ) {
    $searchpostarray = array();
    global $wpdb;
    $results         = $wpdb->get_results( "SELECT * FROM sfe_2_posts p LEFT JOIN sfe_userMeta um ON um.user_id = p.post_author WHERE (um.Meta_key LIKE 'firma_view' AND um.Meta_value LIKE '%" . $word . "%' AND p.post_type = '" . $typ . "' AND p.post_author NOT LIKE '1' AND p.post_status NOT LIKE 'draft') OR (p.post_title LIKE '%" . $word . "%' AND p.post_type = '" . $typ . "' AND p.post_author NOT LIKE '1' AND p.post_status NOT LIKE 'draft') GROUP BY p.id",OBJECT );

    foreach ( $results as $key => $value ) {
        $searchpostarray[] = $value;
    }
    return $searchpostarray;
}

我已经尝试将整个内容创建为Meta_query,但是我不知道如何在Meta查询中比较两个表。

最后,应该从中进行搜索。在此搜索中,将调用功能

有人可以帮我吗?

谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)