NOT IN is not working in sybase?
<p>I have two table lets say <strong>Table1</strong> and <strong>Table2</strong>
and both table have a column Name and ID</p>

<p>I want to fetch all the name from <strong>Table2</strong> which is not in <strong>Table1</strong>
I have written below query :</p>

<pre><code>Select Name,ID FROM Table2 t2 WHERE t2.Name NOT IN (Select t1.Name FROM Table1 t1);
</code></pre>

<p>but this query is not giving expected output, I mean it also gives me Name which is in <strong>Table1</strong>.</p>

<p>I done some google and found it could be if <strong>Table1</strong> have <strong>null</strong> values i.e. If sub-query result contain <strong>null</strong>. although my table doesn't have null values but for making sure this is not a problem I have rewritten query, but without ant luck:</p>

<pre><code>Select Name,ID FROM Table2 t2 WHERE t2.Name 
NOT IN (Select t1.Name FROM Table1 t1 where t1.Name is not null);
</code></pre>

<p>Still I am not getting expected result but strangely some time it gives result as expected and some time not, any suggestion, help will be appreciated. </p>

<p>Is there any bug in sybase 16? I am using sybase 16 with db-visualizer. </p>

<p><strong>UPDATE</strong>
If I have below data</p>

<h2>Table1</h2>

<pre><code>   Name        ID
-------------------
  Jay          1
---------------------
</code></pre>

<h2>Table2</h2>

<pre><code>   Name        ID
-------------------
  Jay          1
  Tom          2
---------------------
</code></pre>

<h2>Expected result</h2>

<pre><code>   Name        ID
-------------------
  Tom          2
---------------------
</code></pre>

<p>but I am getting :</p>

<h2>Result coming</h2>

<pre><code>   Name        ID
-------------------
  Jay          1
  Tom          2
---------------------
</code></pre>

<p><strong>Please note some time I am getting expected result too, not sure why some time it is working as expected and some time not</strong></p>