guitarman fourth grade
Joined: 04 Nov 2005 Posts: 728
|
Posted: Sat Feb 18, 2006 11:42 pm Post subject: mysql NULL column |
|
|
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*
|
|