Show results if column = NULL

Posted on 2012-09-04
Last Modified: 2012-09-04
I'm trying to display results (for a property search in admin).

There's a 'live' column in the database which if  = 1 the property is live, if it's NULL is means the property is part-completed and not live.

I want to display the part-completed properties but can't get the query to work.

Here's what i'm trying:

SELECT properties.propertyID, properties.pricePrefix, images.selected, properties.memberID,, properties.country_code, images.filename,, FORMAT(properties.prices,0) as prices, properties.currency FROM properties INNER JOIN images ON properties.propertyID=images.propertyid WHERE   properties.memberID ='$userid' AND = 'NULL' ORDER by properties.prices ASC

Open in new window

This works fine to display the live properties with = '1' so the query is pretty close. I just can't get it to work with = 'NULL'

Any ideas?database
Question by:BrighteyesDesign
    LVL 12

    Accepted Solution

    You have quotes around the word NULL, so MySQL is treating it like a string.

    The proper syntax is
    ... where columnName is NULL ...

    Open in new window

    so you would want
    ... AND is NULL ...

    Open in new window


    Author Comment


    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Creating and Managing Databases with phpMyAdmin in cPanel.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now