title: How to merge two condition in mysql query?
body: <p>I am new in mysql and php. I want to know how two query merge in mysql. I have table <em>testTable</em> in which :</p>
  
  <pre><code>id     Username1    USername2
  1      A            A
  2      A            B
  3      B            A
  4      A            A
  5      A            C
  6      B            A
  7      A            B
  8      A            A
  </code></pre>
  
  <p>Now I want to write query: (A and B) Or (B ana  A) shows in table only.</p>
  
  <p>Like </p>
  
  <pre><code>2     A     B   
  3     B     A
  6     B     A
  7     A     B
  </code></pre>
  
  <p>thats I want but as I am new so I am not able to do this.</p>
  
  <p>I tried this</p>
  
  <pre><code>$query  = mysql_query("SELECT * FROM tableWriteText WHERE txt_Userame1='$txt_Useram1' AND txt_Userame2='$txt_Userame2'  ORDER BY id ");
  </code></pre>
  
  <p>And send from iphone to php and get </p>
  
  <p>suppose I send from iPhone <code>username1 = A</code> , <code>username2 = B</code></p>
  
  <p>So I get the table</p>
  
  <pre><code>2   A       B
  7   A       B
  </code></pre>
  
  <p>But I want whenever I send from iPhone <code>username1 = A</code> , <code>username2 = B</code></p>
  
  <p>or</p>
  
  <p>Second time I send from iPhone <code>username1 = B</code> , <code>username2 = A</code></p>
  
  <p>Every time, I want to get all A and B  table by order like</p>
  
  <pre><code>2     A     B   
  3     B     A
  6     B     A
  7     A     B
  </code></pre>
  
  <p>For this I tried also this:</p>
  
  <pre><code>$query  = mysql_query("SELECT * FROM tableWriteText WHERE (txt_Userame1='$txt_Useram1' AND txt_Userame2='$txt_Userame2')  OR  (txt_Userame2='$txt_Useram2' AND txt_Userame1='$txt_Userame1')  ORDER BY id ");
  </code></pre>
  
  <p>Any idea or suggestions would be highly welcome.</p>