SQL Query - where field does NOT contain something

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

SQL Query - where field does NOT contain something

Post by simonmlewis »

Code: Select all

$result = mysql_query ("SELECT DISTINCT website FROM returns WHERE dateactioned IS NOT '0000-00-00' NULL ORDER BY website ASC");
This just won't work.

I do plan on setting dateactioned to be a NULL field, but for now, I want this to work.

It has to produce results where the data could be 2009-08-15 for example... and not 0000-00-00.

The error I get is:
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\xampp\phpmyadmin\shop\support\includes\returnscd.inc on line 74
Anyone know how I am being daft here?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
AlanG
Forum Contributor
Posts: 136
Joined: Wed Jun 10, 2009 1:03 am

Re: SQL Query - where field does NOT contain something

Post by AlanG »

Code: Select all

SELECT DISTINCT website 
FROM returns
WHERE dateactioned <> '0000-00-00'
AND dateactioned IS NOT NULL
ORDER BY website ASC
Instead of IS NOT use <>
Post Reply