title: Avoid indirect duplicates in mysql table
body: <p>I don't mean two <em>exactly</em> same rows. </p>
  
  <p>My table's simple structure is something like this:</p>
  
  <p>id val1 val2</p>
  
  <p>val1 and val2 are used to link two objects together, and I can't know which is which because they reference the same table.</p>
  
  <p>I need to avoid the following:</p>
  
  <pre>
  id  val1    val2
  1   40      60
  2   60      40
  </pre>
  
  <p>I can use INSERT IGNORE to avoid direct duplicates, but it doesn't work with the one above.</p>
  
  <p>I'm also trying to avoid multiple queries from PHP, <strong>so I'm asking if it is possible to do this in one SQL query that is sent from PHP.</strong></p>