Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have 2 join queries. I need to union them together. Both of the join queries have a new field say 'str_type'.

I need to make this NULL at for one join and some value in other join which is not making me possible?

$config      = Zend_Registry::get('config');
    $tablePrefix = $config->resources->db->Params->tablePrefix;
    $accidentDetailes1= $this-> getDbTable()->select()
            ->setIntegrityCheck(false)
           ->setIntegrityCheck(false)
            ->from(array("va"=>$tablePrefix."tbl_veh_accident"),"*")
            ->joinLeft(array("ve"=>$tablePrefix."tbl_veh_accident_est"),"va.pk_bint_veh_accident_id=ve.fk_bint_veh_accident_id AND ve.chr_document_status='N'",array("dat_send","vchr_estimated_by","dbl_amount","dat_received","1"=>"str_type","bint_year"=>NULL))

$accidentDetailes2= $this-> getDbTable()->select()
            ->setIntegrityCheck(false)
            ->from(array("va"=>$tablePrefix."tbl_veh_accident"),"*")
            ->joinLeft(array("ve"=>$tablePrefix."tbl_veh_accident_est"),"ve.fk_bint_veh_accident_id=va.pk_bint_veh_accident_id AND ve.chr_document_status='N'",array(
            "dat_send",
            "vchr_estimated_by",
            "dbl_amount",
            "dat_received",,"2"=>"str_type"
            ))
            ->joinLeft(array("vm"=>$tablePrefix."tbl_veh_master"),"vm.pk_bint_veh_master_id=va.fk_bint_veh_master_id",array("bint_year"))

$accidentDetailes = $this->getDbTable()->select()->union(array($accidentDetailes1, $accidentDetailes2));

Here str_type is defined as 1 in first join and 2 in second join respectively. Also bint_year is defined as NULL in first join and some value is setin second table respectively.

But not getting the expected result. It says that NULL is not defined. How can I fix this?

share|improve this question

closed as off topic by JNK Feb 11 at 15:15

Questions on Database Administrators Stack Exchange are expected to relate to database administration within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.