Skip navigation
Currently Being Moderated

SQL Query criteria eliminates too many records

Sep 9, 2009 9:09 AM

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

 
Replies
  • Currently Being Moderated
    Sep 9, 2009 11:57 AM   in reply to aonefun

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

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 9, 2009 8:58 PM   in reply to aonefun

    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?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points