title: Left join return duplicate data although I used GROUP BY
body: <p>SQL: </p>
  
  <pre><code> $sql = "SELECT orders.*,order_products.*,products.*,psettings.*,cities.*,locations.* FROM orders
                  LEFT JOIN order_products ON orders.id=order_products.order_id
                  LEFT JOIN products ON products.id=order_products.product_id
                  LEFT JOIN psettings ON psettings.product_id=order_products.product_id 
                  LEFT JOIN cities ON cities.id=orders.city_id
                  LEFT JOIN locations ON locations.id=orders.location_id
                  WHERE orders.status = '$status'
                  ORDER BY  orders.id  ASC  ";
  </code></pre>
  
  <p>It returns unique data. Here is the returned data:</p>
  
  <pre><code>Array
  (
      [orders] =&gt; Array
          (
              [id] =&gt; 12
              [name] =&gt; Abdus Sattar Bhuiyan
              [email] =&gt; sattar.kuet@gmail.com
              [mobile] =&gt; 01673050495
              [alt_mobile] =&gt; 01818953250
              [city_id] =&gt; 2
              [location_id] =&gt; 5
              [status] =&gt; confirmed
              [cashed] =&gt; 1115
              [created] =&gt; 2015-07-02 01:07:18
              [modified] =&gt; 2015-07-02 01:01:57
              [comment] =&gt; 07/02/2015 06:00 am
          )
  
      [city] =&gt; Array
          (
              [id] =&gt; 2
              [name] =&gt; comilla
          )
  
      [location] =&gt; Array
          (
              [id] =&gt; 5
              [city_id] =&gt; 2
              [name] =&gt; homna
          )
  
      [order_products] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 10
                      [order_id] =&gt; 12
                      [product_id] =&gt; 1
                      [pieces] =&gt; 1
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 11
                      [order_id] =&gt; 12
                      [product_id] =&gt; 2
                      [pieces] =&gt; 1
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 12
                      [order_id] =&gt; 12
                      [product_id] =&gt; 3
                      [pieces] =&gt; 3
                  )
  
          )
  
      [products] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [name] =&gt; নভোযানের নাম সি প্রোগ্রামিং
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-24 16:17:45
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [name] =&gt; Resonance of creativity with C++
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-26 07:32:52
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [name] =&gt; programming by story C
                      [writer] =&gt; Hasibul Hasan Shanto
                      [created] =&gt; 2015-06-26 07:35:57
                  )
  
          )
  
      [psettings] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [product_id] =&gt; 1
                      [img] =&gt; 1.jpg
                      [desc] =&gt; description
                      [created] =&gt; 2015-06-29 15:15:58
                      [bppp] =&gt; 165
                      [sppp] =&gt; 300
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [product_id] =&gt; 2
                      [img] =&gt; 2.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:33:41
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [product_id] =&gt; 3
                      [img] =&gt; 3.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:36:26
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 10
                      [service_charge] =&gt; 30
                  )
  
          )
  
  )
  </code></pre>
  
  <p>But When I Add another table to join left with orders table it returns duplicate entry. Additionally I join left 'action_bies' with orders table as follows:</p>
  
  <pre><code>$sql = "SELECT orders.*,order_products.*,products.*,psettings.*,cities.*,locations.*,action_bies.* FROM orders
              LEFT JOIN order_products ON orders.id=order_products.order_id
               LEFT JOIN action_bies ON orders.id=action_bies.order_id AND action_bies.action='$action'
              LEFT JOIN products ON products.id=order_products.product_id
              LEFT JOIN psettings ON psettings.product_id=order_products.product_id 
              LEFT JOIN cities ON cities.id=orders.city_id
              LEFT JOIN locations ON locations.id=orders.location_id
               WHERE orders.status = '$status'
              ORDER BY  orders.id ASC  ";
  </code></pre>
  
  <p>This sql return duplicate data. Here is the data:</p>
  
  <pre><code> Array
  (
      [orders] =&gt; Array
          (
              [id] =&gt; 12
              [name] =&gt; Abdus Sattar Bhuiyan
              [email] =&gt; sattar.kuet@gmail.com
              [mobile] =&gt; 01673050495
              [alt_mobile] =&gt; 01818953250
              [city_id] =&gt; 2
              [location_id] =&gt; 5
              [status] =&gt; confirmed
              [cashed] =&gt; 1115
              [created] =&gt; 2015-07-02 01:07:18
              [modified] =&gt; 2015-07-02 01:01:57
              [comment] =&gt; 07/02/2015 06:00 am
          )
  
      [city] =&gt; Array
          (
              [id] =&gt; 2
              [name] =&gt; comilla
          )
  
      [location] =&gt; Array
          (
              [id] =&gt; 5
              [city_id] =&gt; 2
              [name] =&gt; homna
          )
  
      [action] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 1
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 0000-00-00 00:00:00
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 4
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 5
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
              [3] =&gt; Array
                  (
                      [id] =&gt; 1
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 0000-00-00 00:00:00
                  )
  
              [4] =&gt; Array
                  (
                      [id] =&gt; 4
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
              [5] =&gt; Array
                  (
                      [id] =&gt; 5
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
              [6] =&gt; Array
                  (
                      [id] =&gt; 1
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 0000-00-00 00:00:00
                  )
  
              [7] =&gt; Array
                  (
                      [id] =&gt; 4
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
              [8] =&gt; Array
                  (
                      [id] =&gt; 5
                      [action] =&gt; confirm
                      [admin_id] =&gt; 30
                      [order_id] =&gt; 12
                      [created] =&gt; 2015-07-02 00:00:00
                  )
  
          )
  
      [order_products] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 10
                      [order_id] =&gt; 12
                      [product_id] =&gt; 1
                      [pieces] =&gt; 1
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 10
                      [order_id] =&gt; 12
                      [product_id] =&gt; 1
                      [pieces] =&gt; 1
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 10
                      [order_id] =&gt; 12
                      [product_id] =&gt; 1
                      [pieces] =&gt; 1
                  )
  
              [3] =&gt; Array
                  (
                      [id] =&gt; 11
                      [order_id] =&gt; 12
                      [product_id] =&gt; 2
                      [pieces] =&gt; 1
                  )
  
              [4] =&gt; Array
                  (
                      [id] =&gt; 11
                      [order_id] =&gt; 12
                      [product_id] =&gt; 2
                      [pieces] =&gt; 1
                  )
  
              [5] =&gt; Array
                  (
                      [id] =&gt; 11
                      [order_id] =&gt; 12
                      [product_id] =&gt; 2
                      [pieces] =&gt; 1
                  )
  
              [6] =&gt; Array
                  (
                      [id] =&gt; 12
                      [order_id] =&gt; 12
                      [product_id] =&gt; 3
                      [pieces] =&gt; 3
                  )
  
              [7] =&gt; Array
                  (
                      [id] =&gt; 12
                      [order_id] =&gt; 12
                      [product_id] =&gt; 3
                      [pieces] =&gt; 3
                  )
  
              [8] =&gt; Array
                  (
                      [id] =&gt; 12
                      [order_id] =&gt; 12
                      [product_id] =&gt; 3
                      [pieces] =&gt; 3
                  )
  
          )
  
      [products] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [name] =&gt; নভোযানের নাম সি প্রোগ্রামিং
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-24 16:17:45
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [name] =&gt; নভোযানের নাম সি প্রোগ্রামিং
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-24 16:17:45
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [name] =&gt; নভোযানের নাম সি প্রোগ্রামিং
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-24 16:17:45
                  )
  
              [3] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [name] =&gt; Resonance of creativity with C++
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-26 07:32:52
                  )
  
              [4] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [name] =&gt; Resonance of creativity with C++
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-26 07:32:52
                  )
  
              [5] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [name] =&gt; Resonance of creativity with C++
                      [writer] =&gt; Engr. Abdus Sattar Bhuiyan
                      [created] =&gt; 2015-06-26 07:32:52
                  )
  
              [6] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [name] =&gt; programming by story C
                      [writer] =&gt; Hasibul Hasan Shanto
                      [created] =&gt; 2015-06-26 07:35:57
                  )
  
              [7] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [name] =&gt; programming by story C
                      [writer] =&gt; Hasibul Hasan Shanto
                      [created] =&gt; 2015-06-26 07:35:57
                  )
  
              [8] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [name] =&gt; programming by story C
                      [writer] =&gt; Hasibul Hasan Shanto
                      [created] =&gt; 2015-06-26 07:35:57
                  )
  
          )
  
      [psettings] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [product_id] =&gt; 1
                      [img] =&gt; 1.jpg
                      [desc] =&gt; description
                      [created] =&gt; 2015-06-29 15:15:58
                      [bppp] =&gt; 165
                      [sppp] =&gt; 300
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [1] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [product_id] =&gt; 1
                      [img] =&gt; 1.jpg
                      [desc] =&gt; description
                      [created] =&gt; 2015-06-29 15:15:58
                      [bppp] =&gt; 165
                      [sppp] =&gt; 300
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [2] =&gt; Array
                  (
                      [id] =&gt; 1
                      [category_id] =&gt; 1
                      [product_id] =&gt; 1
                      [img] =&gt; 1.jpg
                      [desc] =&gt; description
                      [created] =&gt; 2015-06-29 15:15:58
                      [bppp] =&gt; 165
                      [sppp] =&gt; 300
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [3] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [product_id] =&gt; 2
                      [img] =&gt; 2.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:33:41
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [4] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [product_id] =&gt; 2
                      [img] =&gt; 2.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:33:41
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [5] =&gt; Array
                  (
                      [id] =&gt; 2
                      [category_id] =&gt; 1
                      [product_id] =&gt; 2
                      [img] =&gt; 2.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:33:41
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 20
                      [service_charge] =&gt; 30
                  )
  
              [6] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [product_id] =&gt; 3
                      [img] =&gt; 3.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:36:26
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 10
                      [service_charge] =&gt; 30
                  )
  
              [7] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [product_id] =&gt; 3
                      [img] =&gt; 3.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:36:26
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 10
                      [service_charge] =&gt; 30
                  )
  
              [8] =&gt; Array
                  (
                      [id] =&gt; 3
                      [category_id] =&gt; 1
                      [product_id] =&gt; 3
                      [img] =&gt; 3.jpg
                      [desc] =&gt; 
                      [created] =&gt; 2015-06-26 07:36:26
                      [bppp] =&gt; 150
                      [sppp] =&gt; 250
                      [discount] =&gt; 10
                      [service_charge] =&gt; 30
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Here it should be mentioned that a action_bies table has duplicate data as follows:
  <img src="https://i.stack.imgur.com/XGkVm.jpg" alt="enter image description here"></p>
  
  <p>How can I get unique data  in this case. Thanks to read this large data.</p>