Skip to main content
Inspiring
September 9, 2009
Question

SQL Query criteria eliminates too many records

  • September 9, 2009
  • 1 reply
  • 658 views

This SQL query results in zero out of 268 records due to the criteria of (((Products.ProductFamily)<=0))

SELECT images.url_img, images.alt_img, images.productid_img, Products.ProductFamily, Products.ID
FROM images LEFT JOIN Products ON images.productid_img = Products.ID
WHERE (((Products.ProductFamily)<=0));

However, if you change the <=0 to >0, the correct 140 out of 268 records show up. So if 140 records are greater than zero, shouldn't the remaining 128 records be less than or equal to zero? How do I get the results that are <=0 to show up?

FYI - Products.ProductFamily data type is numeric, field size is integer, decimal places is auto, default value is 0, required is No, indexed is No

This topic has been closed for replies.

1 reply

Participating Frequently
September 9, 2009

Question. Why are you using an outer join? Are there cases where you have an image record and no related product record?

aonefunAuthor
Inspiring
September 9, 2009

I've changed the join type but the problem still persists.

Participating Frequently
September 10, 2009

Yes, but can you still answer the question? I am trying to determine if the problem is in the join or the where clause. What happens if you remove the join and still include results from the product table? Can you give an example of data for a few rows (both tables) that are not working as expected?