0
SELECT uls.prod_id,um.prod_image,um.prodname,SUM(msm.points)
FROM tbl_prod_selection AS uls
INNER JOIN tbl_prod_master AS um ON um.prod_id = uls.prod_id
INNER JOIN tbl_admin_prod_selection AS als ON als.user_id = uls.user_id
INNER JOIN tbl_prod_statistics_master AS msm ON (msm.user_id = uls.user_id AND msm.barcode_id = als.barcode_id)
WHERE uls.location_id = "18" AND uls.prod_code = "FLB"
GROUP BY uls.user_id;

can any one help to write zend query for this.

Thanks in Advance.

3
  • I dont know how to write it. I need help, as I am new to zend framework Commented Jul 24, 2014 at 15:32
  • Are you using Zend_Db_Table or just Zend_Db_Adapter? Commented Jul 24, 2014 at 16:12
  • I am using zend_db_table. But in the present code I have to write AND condition for Inner join,but I dont know how to write using zend. can u help me in it Commented Jul 24, 2014 at 17:06

1 Answer 1

1

If you're using Zend_Db_Table, then you can assemble Zend_Db_Table_Select like below:

$select = $model->select()
                ->setIntegrityCheck(false)
                ->from(array('uls' => 'tbl_prod_selection'), array(
                        'uls.prod_id',
                        'um.prod_image',
                        'um.prodname',
                        'sum' => new Zend_Db_Expr('SUM(msm.points)'),
                ))
                ->join(array('um' => 'tbl_prod_master'), 'um.prod_id = uls.prod_id', array())
                ->join(array('als' => 'tbl_admin_prod_selection'), 'als.user_id = uls.user_id', array())
                ->join(array('msm' => 'tbl_prod_statistics_master'), 'msm.user_id = uls.user_id AND msm.barcode_id = als.barcode_id', array())
                ->where('uls.location_id = ?', '18')
                ->where('uls.prod_code = ?', 'FLB')
                ->group('uls.user_id');
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks alot Daniel, that works. But I got error when I include setIntegrityCheck(false) but when I removed it,it worked. Thanks once again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.