我实际上在 virturt mart 表上有三个表,一个是订单,另一个是项目,一个是 order_user_info 以获取用户名我需要加入order_user_info表
但是当我加入时,它显示结果信息加倍,下面我提到了查询和结果,请指导如何避免双重结果
*对于加入名字,我正在使用下面提到的查询 *
LEFT JOIN `urbanite_virtuemart_order_userinfos` 作为 Uinfo ON Uinfo.virtuemart_order_id=i.virtuemart_order_id
*完成查询 *
SELECT SQL_CALC_FOUND_ROWS o.created_on AS 间隔,CAST(i.`created_on` AS DATE) AS created_on, Uinfo.`first_name`, o.`order_number`, SUM(DISTINCT i.product_item_price * product_quantity) as order_subtotal_netto, SUM(DISTINCT i. product_subtotal_with_tax) 作为 order_subtotal_brutto,COUNT(DISTINCT i.virtuemart_order_id) 作为 count_order_id,SUM(i.product_quantity) 作为 product_quantity FROM `urbanite_virtuemart_order_items` 作为 i LEFT JOIN `urbanite_virtuemart_orders` as o ON o.virtuemart_order_id=i.virtuemart_order_id LEFT JOIN `urbanite_virtuemart_order_userinfos` 作为 Uinfo ON Uinfo.virtuemart_order_id=i.virtuemart_order_id AND Uinfo.created_on = i.created_on AND Uinfo.virtuemart_user_id = o.virtuemart_user_id WHERE (`i`.`order_status` = "S") AND i.virtuemart_vendor_id = "63" AND DATE(o.created_on) BETWEEN "2013-06-01 05:00:00" AND "2013-06-30 05" :00:00" 按间隔分组 ORDER BY created_on DESC LIMIT 0, 400
结果我得到了像下面这样的加入
intervals | Created_on | order_no | order_subtotalnetto | order_subtotalbruto | count_order_id | product_quantity
2013-06-12 09:47:16 |2013-06-12 | 43940624 | 200.00000 | 200.00000 | 1 | 2
结果我得到了加入名字,如下所示
intervals | Created_on | order_no | f_name | order_subtotalnetto | order_subtotalbruto | count_order_id | product_quantity
2013-06-12 09:47:16 |2013-06-12 | Fatin Bokhari | 43940624 | 200.00000 | 200.00000 | 1 | 4
在没有加入名字的情况下看到它显示 product_quantity = 2 但是当我加入时它显示值加倍,我尝试了不同但不能这样,因为它每次都显示产品数量 = 1
急需救援!