title: Alternative to nested select statements
body: <p>I have the following tables structure:</p>
  
  <p><img src="https://i.stack.imgur.com/uC3lD.png" alt="enter image description here"></p>
  
  <p>Currently filtering users is implemented by pretty complex nested SQL query (moreover it is automatically generated by Linq). I looks approximately like:</p>
  
  <pre><code>SELECT FROM (SELECT FROM (SELECT FROM ( infinity here...))))
  </code></pre>
  
  <p>Is there a good way to simplify filtering process?</p>
  
  <p>Please, take into account that there are different characteristic types. Here are sub-queries conditions samples:</p>
  
  <pre><code>... WHERE cv.Text like '%aaa%' AND c.Id = 5
  ... WHERE cv.ImageId IS NOT NULL AND c.Id = 10
  ... WHERE cv.Number &gt; 5 AND c.Id = 33
  </code></pre>
  
  <p>etc...</p>
  
  <p>Will appreciate any help and ideas(change DB structure, change technology, etc...), thanks! </p>