?
Solved

Show results if column = NULL

Posted on 2012-09-04
2
Medium Priority
?
553 Views
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.live, properties.country_code, images.filename, properties.name, FORMAT(properties.prices,0) as prices, properties.currency FROM properties INNER JOIN images ON properties.propertyID=images.propertyid WHERE   properties.memberID ='$userid' AND properties.live = 'NULL' ORDER by properties.prices ASC

Open in new window


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

Any ideas?database
0
Comment
Question by:BrighteyesDesign
2 Comments
 
LVL 12

Accepted Solution

by:
zappafan2k2 earned 2000 total points
ID: 38364413
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 properties.live is NULL ...

Open in new window

0
 

Author Comment

by:BrighteyesDesign
ID: 38364436
Cheers!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
The viewer will learn how to dynamically set the form action using jQuery.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

840 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