Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
比较两个表中的字段并在cakephp中获取所需值_Php_Cakephp - Fatal编程技术网

比较两个表中的字段并在cakephp中获取所需值

比较两个表中的字段并在cakephp中获取所需值,php,cakephp,Php,Cakephp,有人能帮我吗请试试这个 select * from posts where p_id in (select distinct p_id from tabs); $sub=$this->tab->find('all',array('fields'=>array('Distinct (tabs.p_id)'))); $sub1=$this->post->find('all',array('conditions'=>array('post.p_id' IN ('

有人能帮我吗请试试这个

select * from posts where p_id in (select distinct p_id from tabs);

$sub=$this->tab->find('all',array('fields'=>array('Distinct (tabs.p_id)')));

$sub1=$this->post->find('all',array('conditions'=>array('post.p_id' IN (' .$sub.')')));

$this->set('mov',$sub1);
$db = $this->Post->getDataSource();
$subQuery = $db->buildStatement(
    array(
        'fields'     => array('"Tabs"."p_id"'),
        'table'      => 'tabs',
        'alias'      => 'Tabs',
        'limit'      => null,
        'offset'     => null,
        'joins'      => array(),
        'conditions' => array(),
        'order'      => null,
        'group'      => null
    ),
    $this->Post
);
$subQuery = ' DISTINCT (Tabs.p_id) IN (' . $subQuery . ') ';
$subQueryExpression = $db->expression($subQuery);
$conditions[] = $subQueryExpression;
$this->Post->find('all', compact('conditions'));
$db = $this->Post->getDataSource();
$subQuery = $db->buildStatement(
    array(
        'fields'     => array('"Tabs"."p_id"'),
        'table'      => 'tabs',
        'alias'      => 'Tabs',
        'limit'      => null,
        'offset'     => null,
        'joins'      => array(),
        'conditions' => array(),
        'order'      => null,
        'group'      => null
    ),
    $this->Post
);
$subQuery = ' DISTINCT (Tabs.p_id) IN (' . $subQuery . ') ';
$subQueryExpression = $db->expression($subQuery);
$conditions[] = $subQueryExpression;
$this->Post->find('all', compact('conditions'));
$sub1=$this->post->find('all',array('conditions'=>array('post.p_id IN ( select distinct p_id from tabs)' )));