FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
mysql NULL column

 
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> Client - Server Side Development
Author Message
guitarman
fourth grade


Joined: 04 Nov 2005
Posts: 728

PostPosted: Sat Feb 18, 2006 11:42 pm    Post subject: mysql NULL column Reply with quote

In MySQL, a column could have a value of NULL if we don't specify as NOT NULL.

To search for all records except those with column(let's say column name as 'Name') with null value we use:

Code:
SELECT * FROM tableName WHERE Name IS NOT NULL

BUT NOT
Code:
SELECT * FROM tableName WHERE Name= NULL
Code:
SELECT * FROM tableName WHERE Name= ''


The purpose I share this is that I have faced the problem of no rows showing at all during one project development and think it's good to share it here.

Hence, if next time you deal with NULL column, do use IS NULL or IS NOT NULL syntax. *wink*

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cambodia eXPlore Forum Index -> Client - Server Side Development All times are GMT + 8 Hours
Page 1 of 1



by phpBB