2016-05-02 14 views
0

私は3つのテーブルを持っていると私は次のクエリを持っている:SQL内部結合は重複を作成します - なぜですか?

SELECT   sfo.status, 
       sfoa.company, 
       sfoa.firstname, 
       sfoa.lastname, 
       sfoa.email, 
       date_format(sfo.shipping_arrival_date,"%d.%m.%Y") AS shipping_arrival_date, 
       sfoi.name, 
       sfoi.qty_ordered, 
FROM sales_flat_order_address AS sfoa 
INNER JOIN sales_flat_order AS sfo ON sfo.entity_id=sfoa.parent_id 
INNER JOIN sales_flat_order_item AS sfoi ON sfoi.order_id=sfo.entity_id 
WHERE sfo.shipping_arrival_date = DATE("2016-05-03 00:00:00") 
    AND (sfo.status = 'processing' 
     OR sfo.status = 'pending') 

結果は、顧客であり、彼が注文。しかし、この情報は繰り返し発生します。そうです

Customer 1 | Item 1 
Customer 1 | Item 2 
Customer 1 | Item 3 
Customer 1 | Item 1 
Customer 1 | Item 2 
Customer 1 | Item 3 
Customer 2 | Item 1 
Customer 2 | Item 2 
Customer 2 | Item 3 
Customer 2 | Item 1 
Customer 2 | Item 2 
Customer 2 | Item 3 
... 

これはなぜですか?私はDISTINCTまたはグループを使用することができますが、なぜそれが起こっているのですか?結合のせいでそれは起こっていますか?私はジョインを使用して、それを処理する最良の方法は何ですか?

ありがとうございました。

編集: SQL構造は次のとおりです。

CREATE TABLE IF NOT EXISTS `sales_flat_order` (
    `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id', 
    `state` varchar(32) DEFAULT NULL COMMENT 'State', 
    `status` varchar(32) DEFAULT NULL COMMENT 'Status', 
    `coupon_code` varchar(255) DEFAULT NULL COMMENT 'Coupon Code', 
    `protect_code` varchar(255) DEFAULT NULL COMMENT 'Protect Code', 
    `shipping_description` varchar(255) DEFAULT NULL COMMENT 'Shipping Description', 
    `is_virtual` smallint(5) unsigned DEFAULT NULL COMMENT 'Is Virtual', 
    `store_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Store Id', 
    `customer_id` int(10) unsigned DEFAULT NULL COMMENT 'Customer Id', 
    `base_discount_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Discount Amount', 
    `base_discount_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Base Discount Canceled', 
    `base_discount_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Discount Invoiced', 
    `base_discount_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Discount Refunded', 
    `base_grand_total` decimal(12,4) DEFAULT NULL COMMENT 'Base Grand Total', 
    `base_shipping_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Amount', 
    `base_shipping_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Canceled', 
    `base_shipping_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Invoiced', 
    `base_shipping_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Refunded', 
    `base_shipping_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Tax Amount', 
    `base_shipping_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Tax Refunded', 
    `base_subtotal` decimal(12,4) DEFAULT NULL COMMENT 'Base Subtotal', 
    `base_subtotal_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Base Subtotal Canceled', 
    `base_subtotal_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Subtotal Invoiced', 
    `base_subtotal_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Subtotal Refunded', 
    `base_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Amount', 
    `base_tax_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Canceled', 
    `base_tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Invoiced', 
    `base_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Refunded', 
    `base_to_global_rate` decimal(12,4) DEFAULT NULL COMMENT 'Base To Global Rate', 
    `base_to_order_rate` decimal(12,4) DEFAULT NULL COMMENT 'Base To Order Rate', 
    `base_total_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Canceled', 
    `base_total_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Invoiced', 
    `base_total_invoiced_cost` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Invoiced Cost', 
    `base_total_offline_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Offline Refunded', 
    `base_total_online_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Online Refunded', 
    `base_total_paid` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Paid', 
    `base_total_qty_ordered` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Qty Ordered', 
    `base_total_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Refunded', 
    `discount_amount` decimal(12,4) DEFAULT NULL COMMENT 'Discount Amount', 
    `discount_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Discount Canceled', 
    `discount_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Discount Invoiced', 
    `discount_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Discount Refunded', 
    `grand_total` decimal(12,4) DEFAULT NULL COMMENT 'Grand Total', 
    `shipping_amount` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Amount', 
    `shipping_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Canceled', 
    `shipping_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Invoiced', 
    `shipping_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Refunded', 
    `shipping_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Tax Amount', 
    `shipping_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Tax Refunded', 
    `store_to_base_rate` decimal(12,4) DEFAULT NULL COMMENT 'Store To Base Rate', 
    `store_to_order_rate` decimal(12,4) DEFAULT NULL COMMENT 'Store To Order Rate', 
    `subtotal` decimal(12,4) DEFAULT NULL COMMENT 'Subtotal', 
    `subtotal_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Subtotal Canceled', 
    `subtotal_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Subtotal Invoiced', 
    `subtotal_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Subtotal Refunded', 
    `tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Tax Amount', 
    `tax_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Tax Canceled', 
    `tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Tax Invoiced', 
    `tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Tax Refunded', 
    `total_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Total Canceled', 
    `total_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Total Invoiced', 
    `total_offline_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Total Offline Refunded', 
    `total_online_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Total Online Refunded', 
    `total_paid` decimal(12,4) DEFAULT NULL COMMENT 'Total Paid', 
    `total_qty_ordered` decimal(12,4) DEFAULT NULL COMMENT 'Total Qty Ordered', 
    `total_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Total Refunded', 
    `can_ship_partially` smallint(5) unsigned DEFAULT NULL COMMENT 'Can Ship Partially', 
    `can_ship_partially_item` smallint(5) unsigned DEFAULT NULL COMMENT 'Can Ship Partially Item', 
    `customer_is_guest` smallint(5) unsigned DEFAULT NULL COMMENT 'Customer Is Guest', 
    `customer_note_notify` smallint(5) unsigned DEFAULT NULL COMMENT 'Customer Note Notify', 
    `billing_address_id` int(11) DEFAULT NULL COMMENT 'Billing Address Id', 
    `customer_group_id` smallint(6) DEFAULT NULL COMMENT 'Customer Group Id', 
    `edit_increment` int(11) DEFAULT NULL COMMENT 'Edit Increment', 
    `email_sent` smallint(5) unsigned DEFAULT NULL COMMENT 'Email Sent', 
    `forced_shipment_with_invoice` smallint(5) unsigned DEFAULT NULL COMMENT 'Forced Do Shipment With Invoice', 
    `gift_message_id` int(11) DEFAULT NULL COMMENT 'Gift Message Id', 
    `payment_auth_expiration` int(11) DEFAULT NULL COMMENT 'Payment Authorization Expiration', 
    `paypal_ipn_customer_notified` int(11) DEFAULT NULL COMMENT 'Paypal Ipn Customer Notified', 
    `quote_address_id` int(11) DEFAULT NULL COMMENT 'Quote Address Id', 
    `quote_id` int(11) DEFAULT NULL COMMENT 'Quote Id', 
    `shipping_address_id` int(11) DEFAULT NULL COMMENT 'Shipping Address Id', 
    `adjustment_negative` decimal(12,4) DEFAULT NULL COMMENT 'Adjustment Negative', 
    `adjustment_positive` decimal(12,4) DEFAULT NULL COMMENT 'Adjustment Positive', 
    `base_adjustment_negative` decimal(12,4) DEFAULT NULL COMMENT 'Base Adjustment Negative', 
    `base_adjustment_positive` decimal(12,4) DEFAULT NULL COMMENT 'Base Adjustment Positive', 
    `base_shipping_discount_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Discount Amount', 
    `base_subtotal_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Base Subtotal Incl Tax', 
    `base_total_due` decimal(12,4) DEFAULT NULL COMMENT 'Base Total Due', 
    `payment_authorization_amount` decimal(12,4) DEFAULT NULL COMMENT 'Payment Authorization Amount', 
    `shipping_discount_amount` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Discount Amount', 
    `subtotal_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Subtotal Incl Tax', 
    `total_due` decimal(12,4) DEFAULT NULL COMMENT 'Total Due', 
    `weight` decimal(12,4) DEFAULT NULL COMMENT 'Weight', 
    `customer_dob` datetime DEFAULT NULL COMMENT 'Customer Dob', 
    `increment_id` varchar(50) DEFAULT NULL COMMENT 'Increment Id', 
    `applied_rule_ids` varchar(255) DEFAULT NULL COMMENT 'Applied Rule Ids', 
    `base_currency_code` varchar(3) DEFAULT NULL COMMENT 'Base Currency Code', 
    `customer_email` varchar(255) DEFAULT NULL COMMENT 'Customer Email', 
    `customer_firstname` varchar(255) DEFAULT NULL COMMENT 'Customer Firstname', 
    `customer_lastname` varchar(255) DEFAULT NULL COMMENT 'Customer Lastname', 
    `customer_middlename` varchar(255) DEFAULT NULL COMMENT 'Customer Middlename', 
    `customer_prefix` varchar(255) DEFAULT NULL COMMENT 'Customer Prefix', 
    `customer_suffix` varchar(255) DEFAULT NULL COMMENT 'Customer Suffix', 
    `customer_taxvat` varchar(255) DEFAULT NULL COMMENT 'Customer Taxvat', 
    `discount_description` varchar(255) DEFAULT NULL COMMENT 'Discount Description', 
    `ext_customer_id` varchar(255) DEFAULT NULL COMMENT 'Ext Customer Id', 
    `ext_order_id` varchar(255) DEFAULT NULL COMMENT 'Ext Order Id', 
    `global_currency_code` varchar(3) DEFAULT NULL COMMENT 'Global Currency Code', 
    `hold_before_state` varchar(255) DEFAULT NULL COMMENT 'Hold Before State', 
    `hold_before_status` varchar(255) DEFAULT NULL COMMENT 'Hold Before Status', 
    `order_currency_code` varchar(255) DEFAULT NULL COMMENT 'Order Currency Code', 
    `original_increment_id` varchar(50) DEFAULT NULL COMMENT 'Original Increment Id', 
    `relation_child_id` varchar(32) DEFAULT NULL COMMENT 'Relation Child Id', 
    `relation_child_real_id` varchar(32) DEFAULT NULL COMMENT 'Relation Child Real Id', 
    `relation_parent_id` varchar(32) DEFAULT NULL COMMENT 'Relation Parent Id', 
    `relation_parent_real_id` varchar(32) DEFAULT NULL COMMENT 'Relation Parent Real Id', 
    `remote_ip` varchar(255) DEFAULT NULL COMMENT 'Remote Ip', 
    `shipping_method` varchar(255) DEFAULT NULL COMMENT 'Shipping Method', 
    `store_currency_code` varchar(3) DEFAULT NULL COMMENT 'Store Currency Code', 
    `store_name` varchar(255) DEFAULT NULL COMMENT 'Store Name', 
    `x_forwarded_for` varchar(255) DEFAULT NULL COMMENT 'X Forwarded For', 
    `customer_note` text COMMENT 'Customer Note', 
    `created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At', 
    `updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At', 
    `total_item_count` smallint(5) unsigned NOT NULL COMMENT 'Total Item Count', 
    `customer_gender` int(11) DEFAULT NULL COMMENT 'Customer Gender', 
    `base_custbalance_amount` decimal(12,4) DEFAULT NULL, 
    `currency_base_id` int(11) DEFAULT NULL, 
    `currency_code` varchar(255) DEFAULT NULL, 
    `currency_rate` decimal(12,4) DEFAULT NULL, 
    `custbalance_amount` decimal(12,4) DEFAULT NULL, 
    `is_hold` int(11) DEFAULT NULL, 
    `is_multi_payment` int(11) DEFAULT NULL, 
    `real_order_id` varchar(255) DEFAULT NULL, 
    `tax_percent` decimal(12,4) DEFAULT NULL, 
    `tracking_numbers` text, 
    `hidden_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Amount', 
    `base_hidden_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Amount', 
    `shipping_hidden_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Hidden Tax Amount', 
    `base_shipping_hidden_tax_amnt` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Hidden Tax Amount', 
    `hidden_tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Invoiced', 
    `base_hidden_tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Invoiced', 
    `hidden_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Refunded', 
    `base_hidden_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Refunded', 
    `shipping_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Shipping Incl Tax', 
    `base_shipping_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Base Shipping Incl Tax', 
    `coupon_rule_name` varchar(255) DEFAULT NULL COMMENT 'Coupon Sales Rule Name', 
    `deposit_amount` decimal(10,4) DEFAULT NULL, 
    `base_deposit_amount` decimal(10,4) DEFAULT NULL, 
    `deposit_amount_refunded` decimal(10,4) DEFAULT NULL, 
    `base_deposit_amount_refunded` decimal(10,4) DEFAULT NULL, 
    `deposit_amount_invoiced` decimal(10,4) DEFAULT NULL, 
    `base_deposit_amount_invoiced` decimal(10,4) DEFAULT NULL, 
    `msp_base_cashondelivery` decimal(12,4) NOT NULL COMMENT 'Msp Base Cashondelivery', 
    `msp_cashondelivery` decimal(12,4) NOT NULL COMMENT 'Msp Cashondelivery', 
    `msp_base_cashondelivery_incl_tax` decimal(12,4) NOT NULL COMMENT 'Msp Base Cashondelivery Incl Tax', 
    `msp_cashondelivery_incl_tax` decimal(12,4) NOT NULL COMMENT 'Msp Cashondelivery Incl Tax', 
    `ebizmarts_abandonedcart_flag` int(1) DEFAULT NULL, 
    `ebizmarts_magemonkey_campaign_id` varchar(10) DEFAULT NULL, 
    `shipping_arrival_date` datetime DEFAULT NULL, 
    `shipping_arrival_comments` text, 
    `shipping_arrival_slot` text, 
    `shipping_arrival_drop` text, 
    `fp_abo` varchar(255) DEFAULT NULL, 
    PRIMARY KEY (`entity_id`), 
    UNIQUE KEY `UNQ_SALES_FLAT_ORDER_INCREMENT_ID` (`increment_id`), 
    KEY `IDX_SALES_FLAT_ORDER_STATUS` (`status`), 
    KEY `IDX_SALES_FLAT_ORDER_STATE` (`state`), 
    KEY `IDX_SALES_FLAT_ORDER_STORE_ID` (`store_id`), 
    KEY `IDX_SALES_FLAT_ORDER_CREATED_AT` (`created_at`), 
    KEY `IDX_SALES_FLAT_ORDER_CUSTOMER_ID` (`customer_id`), 
    KEY `IDX_SALES_FLAT_ORDER_EXT_ORDER_ID` (`ext_order_id`), 
    KEY `IDX_SALES_FLAT_ORDER_QUOTE_ID` (`quote_id`), 
    KEY `IDX_SALES_FLAT_ORDER_UPDATED_AT` (`updated_at`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Sales Flat Order' AUTO_INCREMENT=2402 ; 

-- -------------------------------------------------------- 

-- 
-- Tabellenstruktur für Tabelle `sales_flat_order_address` 
-- 

CREATE TABLE IF NOT EXISTS `sales_flat_order_address` (
    `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Entity Id', 
    `parent_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent Id', 
    `customer_address_id` int(11) DEFAULT NULL COMMENT 'Customer Address Id', 
    `quote_address_id` int(11) DEFAULT NULL COMMENT 'Quote Address Id', 
    `region_id` int(11) DEFAULT NULL COMMENT 'Region Id', 
    `customer_id` int(11) DEFAULT NULL COMMENT 'Customer Id', 
    `fax` varchar(255) DEFAULT NULL COMMENT 'Fax', 
    `region` varchar(255) DEFAULT NULL COMMENT 'Region', 
    `postcode` varchar(255) DEFAULT NULL COMMENT 'Postcode', 
    `lastname` varchar(255) DEFAULT NULL COMMENT 'Lastname', 
    `street` varchar(255) DEFAULT NULL COMMENT 'Street', 
    `city` varchar(255) DEFAULT NULL COMMENT 'City', 
    `email` varchar(255) DEFAULT NULL COMMENT 'Email', 
    `telephone` varchar(255) DEFAULT NULL COMMENT 'Telephone', 
    `country_id` varchar(2) DEFAULT NULL COMMENT 'Country Id', 
    `firstname` varchar(255) DEFAULT NULL COMMENT 'Firstname', 
    `address_type` varchar(255) DEFAULT NULL COMMENT 'Address Type', 
    `prefix` varchar(255) DEFAULT NULL COMMENT 'Prefix', 
    `middlename` varchar(255) DEFAULT NULL COMMENT 'Middlename', 
    `suffix` varchar(255) DEFAULT NULL COMMENT 'Suffix', 
    `company` varchar(255) DEFAULT NULL COMMENT 'Company', 
    `address_id` int(11) DEFAULT NULL, 
    `gift_message_id` int(11) DEFAULT NULL, 
    `tax_id` varchar(255) DEFAULT NULL, 
    `vat_id` text COMMENT 'Vat Id', 
    `vat_is_valid` smallint(6) DEFAULT NULL COMMENT 'Vat Is Valid', 
    `vat_request_id` text COMMENT 'Vat Request Id', 
    `vat_request_date` text COMMENT 'Vat Request Date', 
    `vat_request_success` smallint(6) DEFAULT NULL COMMENT 'Vat Request Success', 
    `msp_base_cashondelivery` decimal(12,4) NOT NULL COMMENT 'Msp Base Cashondelivery', 
    `msp_cashondelivery` decimal(12,4) NOT NULL COMMENT 'Msp Cashondelivery', 
    `msp_base_cashondelivery_incl_tax` decimal(12,4) NOT NULL COMMENT 'Msp Base Cashondelivery Incl Tax', 
    `msp_cashondelivery_incl_tax` decimal(12,4) NOT NULL COMMENT 'Msp Cashondelivery Incl Tax', 
    PRIMARY KEY (`entity_id`), 
    KEY `IDX_SALES_FLAT_ORDER_ADDRESS_PARENT_ID` (`parent_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Sales Flat Order Address' AUTO_INCREMENT=4803 ; 

-- -------------------------------------------------------- 

-- 
-- Tabellenstruktur für Tabelle `sales_flat_order_item` 
-- 

CREATE TABLE IF NOT EXISTS `sales_flat_order_item` (
    `item_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Item Id', 
    `order_id` int(10) unsigned NOT NULL COMMENT 'Order Id', 
    `parent_item_id` int(10) unsigned DEFAULT NULL COMMENT 'Parent Item Id', 
    `quote_item_id` int(10) unsigned DEFAULT NULL COMMENT 'Quote Item Id', 
    `store_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Store Id', 
    `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Created At', 
    `updated_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Updated At', 
    `product_id` int(10) unsigned DEFAULT NULL COMMENT 'Product Id', 
    `product_type` varchar(255) DEFAULT NULL COMMENT 'Product Type', 
    `product_options` text COMMENT 'Product Options', 
    `weight` decimal(12,4) DEFAULT '0.0000' COMMENT 'Weight', 
    `is_virtual` smallint(5) unsigned DEFAULT NULL COMMENT 'Is Virtual', 
    `sku` varchar(255) DEFAULT NULL COMMENT 'Sku', 
    `name` varchar(255) DEFAULT NULL COMMENT 'Name', 
    `description` text COMMENT 'Description', 
    `applied_rule_ids` text COMMENT 'Applied Rule Ids', 
    `additional_data` text COMMENT 'Additional Data', 
    `free_shipping` smallint(5) unsigned NOT NULL COMMENT 'Free Shipping', 
    `is_qty_decimal` smallint(5) unsigned DEFAULT NULL COMMENT 'Is Qty Decimal', 
    `no_discount` smallint(5) unsigned NOT NULL COMMENT 'No Discount', 
    `qty_backordered` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Backordered', 
    `qty_canceled` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Canceled', 
    `qty_invoiced` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Invoiced', 
    `qty_ordered` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Ordered', 
    `qty_refunded` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Refunded', 
    `qty_shipped` decimal(12,4) DEFAULT '0.0000' COMMENT 'Qty Shipped', 
    `base_cost` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Cost', 
    `price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price', 
    `base_price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Base Price', 
    `original_price` decimal(12,4) DEFAULT NULL COMMENT 'Original Price', 
    `base_original_price` decimal(12,4) DEFAULT NULL COMMENT 'Base Original Price', 
    `tax_percent` decimal(12,4) DEFAULT '0.0000' COMMENT 'Tax Percent', 
    `tax_amount` decimal(12,4) DEFAULT '0.0000' COMMENT 'Tax Amount', 
    `base_tax_amount` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Tax Amount', 
    `tax_invoiced` decimal(12,4) DEFAULT '0.0000' COMMENT 'Tax Invoiced', 
    `base_tax_invoiced` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Tax Invoiced', 
    `discount_percent` decimal(12,4) DEFAULT '0.0000' COMMENT 'Discount Percent', 
    `discount_amount` decimal(12,4) DEFAULT '0.0000' COMMENT 'Discount Amount', 
    `base_discount_amount` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Discount Amount', 
    `discount_invoiced` decimal(12,4) DEFAULT '0.0000' COMMENT 'Discount Invoiced', 
    `base_discount_invoiced` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Discount Invoiced', 
    `amount_refunded` decimal(12,4) DEFAULT '0.0000' COMMENT 'Amount Refunded', 
    `base_amount_refunded` decimal(12,4) DEFAULT '0.0000' COMMENT 'Base Amount Refunded', 
    `row_total` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Row Total', 
    `base_row_total` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Base Row Total', 
    `row_invoiced` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Row Invoiced', 
    `base_row_invoiced` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Base Row Invoiced', 
    `row_weight` decimal(12,4) DEFAULT '0.0000' COMMENT 'Row Weight', 
    `gift_message_id` int(11) DEFAULT NULL COMMENT 'Gift Message Id', 
    `gift_message_available` int(11) DEFAULT NULL COMMENT 'Gift Message Available', 
    `base_tax_before_discount` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Before Discount', 
    `tax_before_discount` decimal(12,4) DEFAULT NULL COMMENT 'Tax Before Discount', 
    `weee_tax_applied` text COMMENT 'Weee Tax Applied', 
    `weee_tax_applied_amount` decimal(12,4) DEFAULT NULL COMMENT 'Weee Tax Applied Amount', 
    `weee_tax_applied_row_amount` decimal(12,4) DEFAULT NULL COMMENT 'Weee Tax Applied Row Amount', 
    `base_weee_tax_applied_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Weee Tax Applied Amount', 
    `base_weee_tax_applied_row_amnt` decimal(12,4) DEFAULT NULL COMMENT 'Base Weee Tax Applied Row Amnt', 
    `weee_tax_disposition` decimal(12,4) DEFAULT NULL COMMENT 'Weee Tax Disposition', 
    `weee_tax_row_disposition` decimal(12,4) DEFAULT NULL COMMENT 'Weee Tax Row Disposition', 
    `base_weee_tax_disposition` decimal(12,4) DEFAULT NULL COMMENT 'Base Weee Tax Disposition', 
    `base_weee_tax_row_disposition` decimal(12,4) DEFAULT NULL COMMENT 'Base Weee Tax Row Disposition', 
    `ext_order_item_id` varchar(255) DEFAULT NULL COMMENT 'Ext Order Item Id', 
    `locked_do_invoice` smallint(5) unsigned DEFAULT NULL COMMENT 'Locked Do Invoice', 
    `locked_do_ship` smallint(5) unsigned DEFAULT NULL COMMENT 'Locked Do Ship', 
    `price_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Price Incl Tax', 
    `base_price_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Base Price Incl Tax', 
    `row_total_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Row Total Incl Tax', 
    `base_row_total_incl_tax` decimal(12,4) DEFAULT NULL COMMENT 'Base Row Total Incl Tax', 
    `hidden_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Amount', 
    `base_hidden_tax_amount` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Amount', 
    `hidden_tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Invoiced', 
    `base_hidden_tax_invoiced` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Invoiced', 
    `hidden_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Refunded', 
    `base_hidden_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Hidden Tax Refunded', 
    `is_nominal` int(11) NOT NULL COMMENT 'Is Nominal', 
    `tax_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Tax Canceled', 
    `hidden_tax_canceled` decimal(12,4) DEFAULT NULL COMMENT 'Hidden Tax Canceled', 
    `tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Tax Refunded', 
    `base_tax_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Tax Refunded', 
    `discount_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Discount Refunded', 
    `base_discount_refunded` decimal(12,4) DEFAULT NULL COMMENT 'Base Discount Refunded', 
    `deposit_amount` decimal(10,4) DEFAULT NULL, 
    `base_deposit_amount` decimal(10,4) DEFAULT NULL, 
    `substitute` int(11) DEFAULT NULL, 
    PRIMARY KEY (`item_id`), 
    KEY `IDX_SALES_FLAT_ORDER_ITEM_ORDER_ID` (`order_id`), 
    KEY `IDX_SALES_FLAT_ORDER_ITEM_STORE_ID` (`store_id`) 
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Sales Flat Order Item' AUTO_INCREMENT=20955 ; 
+0

集計関数を使用しない場合、適切な解決策はdistinctの使用です。 – scaisEdge

+2

あなたが小切手を見逃しているため、そこに書かれている必要がある条件が存在する必要があります。 –

+0

スキーマを書き留めて、 –

答えて

1

スキーマなしで確認するのは難しいですが、あなたが見ている重複はそのアドレスの各注文の項目1,2、および3である可能性があります。

関連する問題