[英]SQLSTATE[23000]: Integrity constraint violation: 1052 Column : 'quantite' in field list is ambiguous
I have referenced other questions like mine, but I cannot figure out why I am getting the error in my example. 我引用了其他问题,例如我的问题,但我无法弄清楚为什么我的示例中出现错误。
I have a method that looks like this : 我有一个看起来像这样的方法:
$select = $this->select()->setIntegrityCheck(false)
->from(array('dmas' => $this->_name), array(
'id',
'is_new',
'id_demande',
'id_ds',
'id_station',
'id AS DT_RowId',
'quantite',
'quantite as quantite_initiale',
'quantite_voulue' => new Zend_Db_Expr("quantite -
coalesce(quantite_attribuee, 0)"),
'quantite_attribuee',
'is_attribue',
'num_station',
'id_catalog'
))
->joinLeft(array('cal' => 'catalog_accessory_list'),
'cal.id = dmas.id_catalog', array('id_function1 as id_function_1',
'id_function2 as id_function_2', 'id_function3 as id_function_3'))
->joinLeft(array('cam' => 'catalog_accessory_model'), 'cam.id = cal.id_model', array('name as nom_model', 'id as id_model'))
->joinLeft(array('caf1' => 'catalog_accessory_function1'), 'caf1.id = cal.id_function1', array('name as name_function_1'))
->joinLeft(array('caf2' => 'catalog_accessory_function2'), 'caf2.id = cal.id_function2', array('name as name_function_2'))
->joinLeft(array('caf3' => 'catalog_accessory_function3'), 'caf3.id = cal.id_function3', array('name as name_function_3',
'full_designation' => new Zend_Db_Expr("CONCAT_WS(' | ', cam.name, caf1.name, caf2.name, caf3.name)")))
->joinLeft(array('ds' => 'demande_station'), 'ds.id = dmas.id_ds', array('date_disponibilite' => new Zend_Db_Expr("DATE_FORMAT(ds.disponibilite,'%d/%m/%Y')"),'disponibilite' => new Zend_Db_Expr("DATE_FORMAT(ds.disponibilite,'%d/%m/%Y')"),'date_debut_chantier' => new Zend_Db_Expr("DATE_FORMAT(ds.debut_chantier,'%d/%m/%Y')"),'date_fin_chantier' => new Zend_Db_Expr("DATE_FORMAT(ds.fin_chantier,'%d/%m/%Y')")));
The above query works perfectly. 上面的查询工作完美。 However, when I try to add this joinLeft
I get the error: 但是,当我尝试添加此joinLeft
,出现错误:
->joinLeft(array('a' => 'accessoire'), 'a.id_catalog = dmas.id_catalog', array('id as DT_RowId','nom as code', 'a.quantite as quantite_stock'))
->where('(CAST(dmas.quantite AS SIGNED) - CAST(ifnull(dmas.quantite_attribuee, 0) AS SIGNED)) > 0 '
. 'AND dmas.quantite > 0 AND (dmas.is_attribue <> 1 OR dmas.is_attribue is NULL) '
. 'AND ds.accessoire_valid = 0'
);
The error : 错误 :
SQLSTATE[23000]: Integrity constraint violation: 1052 Column : 'quantite' in field list is ambiguous SQLSTATE [23000]:违反完整性约束:1052列:字段列表中的“ quantite”不明确
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.