0

我正在尝试让 Zend DB 生成以下查询:

SELECT DISTINCT
    US.nombre AS Cliente,
    VE.id_venta,
    VE.fecha,
    VE.total,
    ve.observacion
FROM
    usuarios AS US,
    ventas AS VE

我已经尝试了下面的代码,但它不起作用:

$select = $this->select();
$select->from(array('VE' => 'ventas'), array('id_venta', 'fecha', 'total', 'observacion'))
       ->from(array('US' => 'usuarios'),'ve.id_usuario');
4

1 回答 1

0

我想这就是你要找的:

$select = $this->select();
$select->from(array('US' => 'usuarios'), array('US.nombre as Cliente'))
       ->from(array('VE' => 'ventas'), array('VE.id_venta', 'VE.fecha', 'VE.total', 'VE.observacion'));

这给了我以下输出:

SELECT `US`.`nombre` AS `Cliente`, `VE`.`id_venta`, `VE`.`fecha`, `VE`.`total`, `VE`.`observacion` FROM `usuarios` AS `US` INNER JOIN `ventas` AS `VE`
于 2013-06-16T00:17:46.960 回答