 <p>One way to go about it is to create a view with your basic logic:</p> <pre><code>CREATE VIEW myview AS SELECT * FROM mytable WHERE column_b = 'X' AND column_c = 'Y' </code></pre> <p>Now, this logic can be reused:</p> <pre><code>SELECT * FROM myview WHERE column_a NOT IN (SELECT column_k FROM myview) </code></pre>