title: what is inequality join in mysql,how it works
body: <p>dealer table</p>
  
  <pre><code>ID | Product
  ------------
  1   product1
  1   product2
  1   product3
  1   product4
  2   product1
  2   product2
  2   product3
  3   product1
  3   product2
  3   product3
  4   product1
  4   product2
  </code></pre>
  
  <p>i want to find all id and its top 2 product</p>
  
  <p>my try is</p>
  
  <pre><code>  select d1.id,d1.product,count(d1.product)
    from dealer d1 join
         dealer d2  
         on d1.id=d2.id
    where d1.product&gt;=d2.product
    group by d1.id,d1.product
   having count(d1.product)&lt;=2
  </code></pre>
  
  <p>my result is</p>
  
  <pre><code>id |product   |count(d1.product) 
  ----------------------------
  1   product1    1
  1   product2    2
  2   product1    1
  2   product2    2
  3   product1    1
  3   product2    2
  4   product1    1
  4   product2    2
  </code></pre>
  
  <p>google search says i got proper result due to inequality join but i want to know how inequality join working in this</p>