SQLSTATE [23000]:完整性约束违规:1052列:字段列表中的“quantite”不明确

时间:2018-02-25 15:08:17

标签: sql constraints fieldlist

我引用了其他类似我的问题,但我无法弄清楚为什么我在我的例子中收到错误。

我有一个看起来像这样的方法:

$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')")));

以上查询完美无缺。但是,当我尝试添加此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'
                );

错误:

  

SQLSTATE [23000]:完整性约束违规:1052列:字段列表中的“quantite”不明确

0 个答案:

没有答案