MySQL statement set (i)

Source: Internet
Author: User
Tags joins

SELECT            ucentertdoulog.user_id, Ucentertdoulog.subject, ucentertdoulog.tdou,ucentertdoulog.created,            ucentertdoulog.out_id, Ifnull (SALEORDER.ORDER_SN, 0) as ORDER_SN,            (                SELECT                    SUM (Tdou)                    from Ucenter_tdou_log as a                WHERE                    a.created <= ucentertdoulog.created and                    a.user_id = ucentertdoulog.user_id                GROUP by                    a.user_id            ) as Tdou_total        from            Ucenter_tdou_log as Ucentertdoulog left            JOIN Sale_order as Saleorder on saleorder.order_id = ucentertdoulog.out_id        WHERE             1=1%s        order             by UCENTERTDOULOG.USER_ID asc,ucentertdoulog.created ASC

Send and save summary

SELECT goodssku.sku_id, Goodssku.barcode, Goodssku.sku_name, Goodstypespec 1.spec_name as SKU_SPEC1, goodstypespec2.spec_name as SKU_SPEC2, goodscategory1.cat_name as CatNam E1, Goodscategory2.cat_name as CatName2, goodscategory3.cat_name as CatName3, Goodsuni T.sale_unit, Sellerbase.seller_name, Ifnull ((SELECT SUM (wmsbatchitem.sku_num) from Wms_batch_base As Wmsbatchbase INNER JOIN Wms_batch_item as wmsbatchitem on wmsbatchitem.batch_id = wmsbatchbase.batch_id WHERE WmsBatchI tem.sku_id = goodssku.sku_id%s), 0) as Qichunum, Ifnull ((SELECT SUM (Wmsbatchitem.sku_num * WMSBATCHITEM.SKU_PR ICE) from Wms_batch_base as Wmsbatchbase INNER joins Wms_batch_item as Wmsbatchitem on wmsbatchitem.batch_id = Wmsbatchbas e.batch_id WHERE wmsbatchitem.sku_id = goodssku.sku_id%s), 0) as Qichuprice, Ifnull ((SELECT SUM (WMSBATCHITEM.S Ku_num) from Wms_batch_bASE as Wmsbatchbase INNER JOIN Wms_batch_item as wmsbatchitem on wmsbatchitem.batch_id = wmsbatchbase.batch_id WHERE WmsBa tchitem.sku_id = goodssku.sku_id and wmsbatchbase.type_id not in (02,05)%s), 0) as Batchnum, Ifnull ((SELECT SUM (Wmsbatchitem.sku_num * wmsbatchitem.sku_price) From Wms_batch_base as Wmsbatchbase INNER joins Wms_batch_item as Wmsbatchitem on wmsbatchitem.batch_id = WMSBATCHBASE.BATC             h_id WHERE wmsbatchitem.sku_id = goodssku.sku_id and wmsbatchbase.type_id not in (02,05)%s), 0) as Batchprice,  Ifnull ((SELECT SUM (wmsbatchitem.sku_num) from Wms_batch_base as Wmsbatchbase INNER JOIN Wms_batch_item as Wmsbatchitem on wmsbatchitem.batch_id = wmsbatchbase.batch_id WHERE wmsbatchitem.sku_id = goodssku.sku_id and WmsBatchBase.type_id = 02 s), 0) as Allocbatchnum, Ifnull ((SELECT SUM (Wmsbatchitem.sku_num * wmsbatchitem.sku_price) from Wms_batch_base As Wmsbatchbase INNER JOIN Wms_batch_item as wmsbatchitem on wmsbatchitem.batch_id = Wmsbatchbase.batch_id where wmsbatchitem.sku_id = goodssku.sku_id and wmsbatchbase.type_id =%s), 0) as Allocbatchprice,  Ifnull ((SELECT SUM (wmsbatchitem.sku_num) from Wms_batch_base as Wmsbatchbase INNER JOIN Wms_batch_item as Wmsbatchitem on wmsbatchitem.batch_id = wmsbatchbase.batch_id WHERE wmsbatchitem.sku_id = goodssku.sku_id and WmsBatchBase.type_id = 05 s), 0) as Takebatchnum, Ifnull ((SELECT SUM (Wmsbatchitem.sku_num * wmsbatchitem.sku_price) from Wms_batch_base A S wmsbatchbase INNER JOIN Wms_batch_item as wmsbatchitem on wmsbatchitem.batch_id = wmsbatchbase.batch_id WHERE WmsBatchIt em.sku_id = goodssku.sku_id and wmsbatchbase.type_id =%s), 0) as Takebatchprice, Ifnull ((SELECT SUM (Wmsorde Ritem.sku_num) from Wms_order_base as Wmsorderbase INNER JOIN Wms_order_item as wmsorderitem on wmsorderitem.order_id = Wm sorderbase.order_id where wmsorderitem.sku_id = goodssku.sku_id and wmsorderbase.type_id not in (01,05)%s), 0) as OrderNum , Ifnull (SELECT SUM (Wmsorderitem.sku_num * wmsorderitem.stock_price) from wms_order_base as Wmsorderbase INNER JOIN Wms_order_item as Wmsorderitem on wmsorderitem.order_id = wmsorderbase.order_id WHERE wmsorderitem.sku_id = goodssku.sku_id and WmsOrderBa se.type_id not in (01,05)%s), 0) as Orderprice, Ifnull ((SELECT SUM (wmsorderitem.sku_num) from Wms_order_base A S wmsorderbase INNER JOIN Wms_order_item as wmsorderitem on wmsorderitem.order_id = wmsorderbase.order_id WHERE WmsOrderIt em.sku_id = goodssku.sku_id and wmsorderbase.type_id =%s), 0) as Allocordernum, Ifnull ((SELECT SUM (wmsorder Item.sku_num * wmsorderitem.stock_price) from Wms_order_base as Wmsorderbase INNER joins Wms_order_item as WmsOrderItem on wmsorderitem.order_id = wmsorderbase.order_id WHERE wmsorderitem.sku_id = goodssku.sku_id and WmsOrderBase.type_id = 01 s), 0) as Allocorderprice, Ifnull ((SELECT SUM (wmsorderitem.sku_num) from Wms_order_base as Wmsorderbase INNER JOIN Wms_order_item as WmsoRderitem on wmsorderitem.order_id = wmsorderbase.order_id WHERE wmsorderitem.sku_id = goodssku.sku_id and wmsorderbase.type_id =%s), 0) as Takeordernum, Ifnull ((SELECT SUM (Wmsorderitem.sku_num * wmsorderitem.stock _price) from Wms_order_base as Wmsorderbase INNER JOIN Wms_order_item as wmsorderitem on wmsorderitem.order_id = WmsOrderB ase.order_id where wmsorderitem.sku_id = goodssku.sku_id and wmsorderbase.type_id =%s), 0) as Takeorderprice FR OM Goods_sku as Goodssku INNER JOIN goods_base as goodsbase on goodssku.goods_id = Goodsbase.goods _id left JOIN goods_category as GoodsCategory1 on goodscategory1.cat_id = Goodsbase.cat_id1 left J OIN goods_category as GoodsCategory2 on goodscategory2.cat_id = Goodsbase.cat_id2 left JOIN goods_category as GoodsCategory3 on goodscategory3.cat_id = Goodsbase.cat_id3 left joins Goods_unit as Goodsunit on Goodsunit.uni t_id = goodsbase.unit_id LEFT join Seller_base as sellerbase on sellerbase.seller_id = goodsbase.seller_id left JOIN Goods_type_spec as Go ODSTYPESPEC1 on goodstypespec1.spec_id = Goodssku.sku_spec1 left joins Goods_type_spec as GOODSTYPESPEC2 on Goo dstypespec2.spec_id = goodssku.sku_spec2 LIMIT%d,%d

/** * Receive and save summary report * @param $houseID * @param $startDate * @param $endDate * @param $page * @param int $size * @return Array */Public function Fetchorderbatchallreport ($houseID, $startDate, $endDate, $page, $size        =) {$database = $this->database ();        $where 1 = ";        $where 2 = ";        $where 3 = ";        $where 4 = ";        $where 5 = ";        $where 6 = ";        $where 7 = ";        $where 8 = ";        $where 9 = ";        $where 10 = ";        $where 11 = ";        $where 12 = ";        $where 13 = ";        $where 14 = ";        $params 1 = array ();        $params 2 = array ();        $params 3 = array ();        $params 4 = array ();        $params 5 = array ();        $params 6 = array ();        $params 7 = array ();        $params 8 = array ();        $params 9 = array ();        $params = Array ();        $params one = array ();        $params = Array ();        $params = Array ();        $params = Array (); if ($houseID) {            $where 1. = ' and wmsbatchbase.house_id =? ';            $where 2. = ' and wmsbatchbase.house_id =? ';            $where 3. = ' and wmsbatchbase.house_id =? ';            $where 4. = ' and wmsbatchbase.house_id =? ';            $where 5. = ' and wmsbatchbase.house_id =? ';            $where 6. = ' and wmsbatchbase.house_id =? ';            $where 7. = ' and wmsbatchbase.house_id =? ';            $where 8. = ' and wmsbatchbase.house_id =? ';            $where 9. = ' and wmsorderbase.house_id =? ';            $where. = ' and wmsorderbase.house_id =? ';            $where. = ' and wmsorderbase.house_id =? ';            $where. = ' and wmsorderbase.house_id =? ';            $where. = ' and wmsorderbase.house_id =? ';            $where 14.= ' and wmsorderbase.house_id =? ';            Array_push ($params 1, $houseID);            Array_push ($params 2, $houseID);            Array_push ($params 3, $houseID);            Array_push ($params 4, $houseID); Array_push ($params 5, $houseID);            Array_push ($params 6, $houseID);            Array_push ($params 7, $houseID);            Array_push ($params 8, $houseID);            Array_push ($params 9, $houseID);            Array_push ($params, $houseID);            Array_push ($params, $houseID);            Array_push ($params, $houseID);            Array_push ($params, $houseID);        Array_push ($params, $houseID);            } if ($startDate && $endDate) {$started = Strtotime ($startDate);            $ended = Strtotime ($endDate);            $where 1. = ' and wmsbatchbase.created <=? ';            $where 2. = ' and wmsbatchbase.created <=? '; $where 3. = ' and wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 4. = ' and wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 5. = ' and wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 6. = ' AnD wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 7. = ' and wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 8. = ' and wmsbatchbase.created >=? and wmsbatchbase.created-(24*60*60) <=?            ‘; $where 9. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘; $where. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘; $where. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘; $where. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘; $where. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘; $where. = ' and wmsorderbase.created >=? and wmsorderbase.created-(24*60*60) <=?            ‘;            Array_push ($params 1, $started); Array_push ($pARAMS2, $started);            Array_push ($params 3, $started, $ended);            Array_push ($params 4, $started, $ended);            Array_push ($params 5, $started, $ended);            Array_push ($params 6, $started, $ended);            Array_push ($params 7, $started, $ended);            Array_push ($params 8, $started, $ended);            Array_push ($params 9, $started, $ended);            Array_push ($params, $started, $ended);            Array_push ($params, $started, $ended);            Array_push ($params, $started, $ended);            Array_push ($params, $started, $ended);        Array_push ($params, $started, $ended); } $params =array_merge ($params 1, $params 2, $params 3, $params 4, $params 5, $params 6, $params 7, $params 8, $params 9,$        PARAMS10, $params, $params, $params, $params 14);  Return Array ($database->query (sprintf (Self::order_batch_all_report_sql, $where 1, $where 2, $where 3, $where 4, $where 5, $where 6, $where 7, $where 8, $where 9, $where, $where, $wheRe12, $where, $where, ($page-1) * $size, $size), $params, databaseprovider::fetch_style_obj), $database-&gt    ; query (Self::order_batch_all_report_count_sql),); }

  

MySQL statement set (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.