title: SQL: How to use conditions AND and OR in Sql
body: <p>I have table with the following value</p>
  
  <pre><code>docid dcname doctitle 
  1      **aa   **aaa01-01 
  2      aa**   aafddg-02**
  3      a**a   asds***90-05
  4      abcd   abcd-06.
  </code></pre>
  
  <p>Now in this table i want to filter the "Doctitles" values beginning and ending with **</p>
  
  <p>my result should be </p>
  
  <pre><code>dcid docname doctitle
  3    a**a    asds***90-05
  4    abcd    abcd-06
  </code></pre>
  
  <p>i am using the below query but the result obtained is only Doctitles with ** in the middle</p>
  
  <pre><code>SELECT *
    FROM table1
   WHERE     doctitle NOT LIKE '**%'
         AND doctitle NOT LIKE '%**'
         AND doctitle LIKE '%**%'
  </code></pre>
  
  <p>this gives me only below result
  dcid docname doctitle
  3    a*<em>a    asds</em>**90-05 </p>
  
  <p>Need help on this .</p>