Pretty easy really
SELECT * FROM foo WHERE bar is NULL
- DON'T use quotes "NULL" is a valid string it is not the same as NULL
- Some DBMS's allow you to say bar = NULL but technically this is wrong
because NULL is undefined and cannot be equal to anything not even another
- Also "" is not NULL - be sure you blank fields are NULL and not ""
- A clever way to search for both "" and NULL in the same query is:
SELECT * FROM foo WHERE NOT bar > ""
This may not work in all DBMS's but give it a try; OR would work too.
On 2/26/02 2:20 PM, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> From: "Robin McKenzie" <[EMAIL PROTECTED]>
> Date: Tue, 26 Feb 2002 21:49:00 -0000
> To: [EMAIL PROTECTED]
> Subject: Finding records with NULL values
> I have a table of questions, and a table of responses (initially empty)
> which gets updated every time an answer is submitted, with the question
> number, member id and response.
> I wish to produce a SELECT query that will find the questions that haven't
> been answered by a particular member, i.e. a query that finds the questions
> that DO NOT have an entry in responses. How can I do this?
Poet, Artist & Mystic
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php