MySql and NULL

siLk

OSNN Newbie
Joined
13 Jan 2004
Messages
6
When checking the database to see if a value has been inserted into a field marked NULL do you actually check it as NULL or do you check it as an empty string ( "" ) ?
 
an empty string is not a NULL. if its NULL then it needs to be checked as NULL. If you've inserted it as a blank string the it is not null
 
NULL and a blank string are basically the same thing in MySQL Khayman, they both mean the field is empty, and both will suffice.

So this:

SELECT * FROM table WHERE string = '';

is the same as

SELECT * FROM table WHERE string = 'NULL';
 
Does it? thats pretty stupid, that was the whole point of NULL.
Doesn't in any other SQL DBMS.
 
Khayman said:
Does it? thats pretty stupid, that was the whole point of NULL.
Doesn't in any other SQL DBMS.


I have always used it interchangeably with MySQL, like you said, no other ones do it.
 
as no others do it, then probably better to use the version with NULL in it as it will make your code more portable should you want to change your RDBMS to something else, also makes learning the syntax or getting used to the syntax of other RDBMS's a slight bit easier
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,620
Latest member
alexexists11
Back