title: DISTINCT ON two fields MYSQL + rails
body: <p>I have a model Message which consists of :title,:description,:sender_id,:receiver_id. So Records of Message Model may</p>
  
  <ol>
  <li><p>Message.first
  (id:1, title: "Sample1", description: "Test1", sender_id: 1, receiver_id: 2)</p></li>
  <li><p>Message.second
  (id:1, title: "Sample2", description: "Test2", sender_id: 3, receiver_id: 4)</p></li>
  <li><p>Message.second
  (id:1, title: "Sample3", description: "Test2", sender_id: 3, receiver_id: 4)</p></li>
  </ol>
  
  <p>I want a query which gives distinct record based on sender_id and receiver_id</p>
  
  <p>In Postgres
  Message.select("DISTINCT ON (sender_id, receiver_id) *")  works</p>
  
  <p>But MYSQL2 giving error please help </p>
  
  <p>Edit</p>
  
  <p>Work around from me</p>
  
  <pre><code>messages = [] 
  messages &lt;&lt; Message.all.to_a.uniq{|m| m.sender_id} 
  messages &lt;&lt; Message.all.to_a.uniq{|m| m.receiver_id} 
  @messages = messages.flatten.uniq
  </code></pre>