title: Select Query with OR and NAND
body: <p>I am trying to design a query with OR and NAND operation, Can some one let me know Is the query is correct:</p>
  <h1>Question 1: Is this query correct?</h1>
  <pre><code>select * from country where country_code='AL' UNION (SELECT * from country
  WHERE country_id NOT IN
         (SELECT country_id from country
                where country_name='Land islands'
          UNION
          SELECT country_id from country
                 where country_code='AX'
          ));
  </code></pre>
  <p>I created the query with the help of my another question of mine;</p>
  <p><a href="https://stackoverflow.com/questions/16938865/mysql-with-multiple-query-having-nand-opertaion-and-not-operation">Ref:</a></p>
  <h1>Question 2:</h1>
  <p>I want to use 5 query with AND,NOT,NAND,OR operation in between them.
  I created up to 3 (Check my Question 1) I need help for creating 5 Select Queries.</p>
  <p>My Application is search application where the user can search the database with i5 query block in between each block we have operations like below I mentioned. But the operations are carried out in one single table.</p>
  <p>Explanation:</p>
  <p>I want to select records inside a table and I will use many operations in between the table. MAX 5 operation in side a query.</p>
  <p>Query 1,Query 2, Query 3, Query 4, Query 5.</p>
  <p>Cases:</p>
  <pre><code>(Query 1 AND Query 2 OR  Query 3 NAND Query 4 NOT Query 5)
  (Query 1 OR Query 2 OR  Query 3 OR Query 4 OR Query 5)
  (Query 1 AND Query 2 AND Query 3 AND Query 4 AND Query 5)
  (Query 1 NOT Query 2 NOT Query 3 NOT Query 4 NOT Query 5)
  </code></pre>
  <p>etc.. The operation in between the query Block may vary... I will write my PHP script according to that but I want to perform the Logic in such a way that I can join each logic..</p>
  <p>Now I need an help</p>