title: Extract all rows of a column based on the value of another column (SQL query)
body: <p>I have table </p>
  
  <pre><code>a | b 
  ----- 
  1 | 3 
  3 | 2 
  3 | 4 
  2 | 5 
  3 | 6 
  2 | 7
  </code></pre>
  
  <p>how to write sql query if a = 1 then result 3 2 4 5 6 7, if a = 3 then 2 4 5 6 7, if 2 then 5 7
  here is my query</p>
  
  <pre><code>select * 
  from table
  where a in (select b from table where a = 1) or a = 1
  </code></pre>
  
  <p>but the result only 3 2 4 6 because 3 has 2 in col b so i want also to have 5 7
  thanks</p>