How to test for null (mysql)?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

How to test for null (mysql)?

Post by Chalks »

How would I test if a table value is null?

Code: Select all

$sql = "SELECT id FROM pages WHERE cat='" . $oldcat . "' AND page=null";
That doesn't work, but it shows exactly what I'm trying to do. Help, please! :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Code: Select all

WHERE page IS NULL 
or

Code: Select all

WHERE page IS NOT NULL
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Post by Chalks »

That makes my code so much easier to design... thank you, thank you, thank you. :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

heh, your welcome, your welcome, your welcome.
Post Reply