Zend中查询联盟的区别

I want to get 'DISTINCT(ITEMS)' from the two sub queries, but it gives me an error. Also cannot apply distinct to each query because the tables are different.

 $sql1 = $zdb->select()
        ->from($table1, array('id','items'))
        ->where('data    = ?', $arrData['data']);
    $sql2 = $zdb->select()
        ->from($table2, array('id','items'))
        ->where('data    = ?', $arrData['data']);
    $select = $zdb->select('DISTINCT(items)')->union(array($sql1, $sql2));

Pls help me thanks in advance

If I'm not mistaken, you can try this:

$select = $zdb->select()->distinct()->union(array($sql1, $sql2));

As second parameter you can pass the Zend_Db_Select::SQL_UNION or Zend_Db_Select::SQL_UNION_ALL constants to specify which type of union you want to perform.