How can I join a subquery using Zend_Db_Select

后端 未结 1 2067
悲哀的现实
悲哀的现实 2021-02-20 11:24

How would I construct this query using Zend_Db_Select?:

SELECT users.user_id, email_address, t1.value as \'languages\'    
FROM users
LEFT JOIN (
           


        
1条回答
  •  一整个雨季
    2021-02-20 11:57

    $user_multivalued = $db
        ->select()
        ->from('user_multivalued', array(
            'user_id',
            'field_id',
            new Zend_Db_Expr("GROUP_CONCAT(value SEPARATOR ',') AS value")
        ))
        ->where('field = ?', 25)
        ->group('user_id')
        ->group('field_id')
    ;
    
    $select = $db
        ->select()
        ->from('users', array('user_id', 'email_address'))
        ->joinLeft(
            array('t1' => $user_multivalued),
            't1.user_id = users.user_id',
            array('languages'=>'value')
        )
        ->where('list_id = ?', 45)
    ;
    

    0 讨论(0)
提交回复
热议问题