title: SQL Query: Join causes triplicate result
body: <p><strong>Program</strong>  SQL using mySQL (phpMyAdmin) &amp; MySQL Workbench<br>
  <strong>Skill level</strong>  None to speak of<br>
  <strong>Note</strong> The /<em>PREFIX</em>/ came with the SQL I contracted to be written 18 months ago.</p>
  
  <p>Hi there,<br>
  I am trying to retrieve the Country, CountryID &amp; State from my SQL database.<br>
  Unfortunately It is required that a second join be used as Country is in (orders T5); CountryID &amp; State in (address_book T7).  </p>
  
  <p>From what I have read it could be too many joins?  (I'm a little confused).  </p>
  
  <p>The Join causing the issue (I have tried: Inner, Left, Right joins):</p>
  
  <pre><code>left Join /*PREFIX*/address_book T7 On (T7.customers_id = T5.customers_id)
  </code></pre>
  
  <p>The full FROM clause:</p>
  
  <pre><code>From /*PREFIX*/products T1
      Left Join /*PREFIX*/orders_products T2 On (T1.products_id = T2.products_id)
      Inner Join /*PREFIX*/orders T5 On (T5.orders_id = T2.orders_id)
      Inner Join /*PREFIX*/products_description T3 On (T1.products_id = T3.products_id)
      Inner Join /*PREFIX*/customers T6 On (T5.customers_id = T6.customers_id)
      **left Join /*PREFIX*/address_book T7 On (T7.customers_id = T5.customers_id)**
      Left Join /*PREFIX*/paypal P1 On (P1.order_id = T5.orders_id)
      Left Join /*PREFIX*/manufacturers T4 On (T1.manufacturers_id = T4.manufacturers_id)
      Where (T5.date_purchased &gt;= 20120101) 
      And (T5.date_purchased &lt;= 20140227) 
      And T5.orders_status = 1
  </code></pre>
  
  <p>The query contains all store order information</p>
  
  <pre><code>Select
  -- Other store Query --
  
  -- Customer Information --
      T5.customers_id As CID,
      T6.customers_firstname As CFirst,
      T6.customers_lastname As CLast,
      T5.customers_name As CName,
      T5.customers_email_address As CEmail,
      T5.customers_country As CCountry,
  
      -- Following 2 lines from the 'FROM'
      T7.entry_country_id As CCountryID,
      T7.entry_state As CState,
  </code></pre>
  
  <p>I know it could do with some tidying, but I am not much more than a beginner at SQL, just enough to troubleshoot little bits of code, and paste it back together.  </p>
  
  <p>Using Copy/Create Statement</p>
  
  <pre><code>CREATE TABLE `address_book` (
    `address_book_id` int(11) NOT NULL AUTO_INCREMENT,
    `customers_id` int(11) NOT NULL DEFAULT '0',
    `entry_gender` char(1) NOT NULL DEFAULT '',
    `entry_company` varchar(64) DEFAULT NULL,
    `entry_firstname` varchar(32) NOT NULL DEFAULT '',
    `entry_lastname` varchar(32) NOT NULL DEFAULT '',
    `entry_street_address` varchar(64) NOT NULL DEFAULT '',
    `entry_suburb` varchar(32) DEFAULT NULL,
    `entry_postcode` varchar(10) NOT NULL DEFAULT '',
    `entry_city` varchar(32) NOT NULL DEFAULT '',
    `entry_state` varchar(32) DEFAULT NULL,
    `entry_country_id` int(11) NOT NULL DEFAULT '0',
    `entry_zone_id` int(11) NOT NULL DEFAULT '0',
    PRIMARY KEY (`address_book_id`),
    KEY `idx_address_book_customers_id_zen` (`customers_id`)
      ) ENGINE=MyISAM AUTO_INCREMENT=2917 DEFAULT CHARSET=utf8;
  </code></pre>