Why no worky?
October 21, 2006 5:42 PM
Subscribe
SQLServerFilter: Quick question about views and using "NOT IN".
Okay, this should be easy, but for some reason my query isn't returning the desired results. I have a view, vwPO, with one field called poNumber. I have a table called purchaseOrders with many fields, one of which is also called poNumber.
vwPO is not generated from the purchaseOrders table. vwPO has 19,925 distinct records, purchaseOrders has 20,382 distinct records.
I need to return all poNumbers in vwPO that are not in the purchaseOrders table.
If I run the following query, I get nothing, an empty recordset:
SELECT ponumber FROM vwPO WHERE poNumber NOT IN (SELECT ponumber FROM purchaseorders)
If I use IN instead of NOT IN, the query returns 19661 records. Why is my first query not returning the 264 poNumbers?
I know for a fact that there are poNumbers in the view that are not in the table, I just don't understand why they aren't being returned.
Admittedly my brain is fried right now and I feel like I'm missing something easy....but at the moment, I don't get it.
Help, please! Thanks!
posted by SoulOnIce to technology (4 comments total)
1 user marked this as a favorite
posted by Doofus Magoo at 6:46 PM on October 21, 2006