MySQL Forums
Forum List  »  Newbie

Re: Selecting only records that exist
Posted by: Jay Pipes
Date: June 25, 2005 12:13PM

Other than you naming the field the same as the table, you're almost there. Use a table alias so you don't get confused.

SELECT DISTINCT r.cover_picture, r.artist, r.albums, r.review
FROM review r
WHERE r.live=1
AND r.review IS NOT NULL
ORDER BY r.review_id
LIMIT 9

Also, be sure that your review field actually contains NULL values, and not empty strings (''). It's a common source of results being returned that you didn't expect to.

Check the application code that is inserting your review records to ensure that a NULL value is manually being inserted into the review field if there is no review. If you've set the review field up to allow NULL values, but have a default value set to '', then the fields will be filled with empty strings, not NULL values, if you didn't specifically tell MySQL to store a NULL value in the review field.

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
Re: Selecting only records that exist
June 25, 2005 12:13PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.