MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 22nd, 2000, 07:39 PM
jprophet jprophet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 2 jprophet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
In the New Riders MySQL book (which is awesome, by the way) page 99, there's a reference to using a CHAR(0) field as a super-efficient ON/OFF flag (it only uses one bit).

CHAR(0) can have two values, either NULL or the empty string. Using IS NULL, I can detect my column RType (which I set to CHAR(0)) as being NULL or empty string - this does work, as I've checked it with known NULL and non-null values (I've also tried IFNULL and ISNULL() as well).

However, it seems I can't set RType to anything other than NULL

In this example, I create a record where Rtype is NULL.

Then I try to set all the RType values to an empty string ('') to get it to be somethign other than NULL (I even tried setting RType to '1').


Finally, I do a search for all records where RType is NULL. I'm thinking that this should return NO records, but I get them all back.

Is there another way to set a column's value(I'm using MySQL 3.23.7) ?

_____________

<this is in PHP>

$ query = " INSERT INTO R2000 (Qno, RType) VALUES (333,NULL) ";

$result= mysql_query($query);

$query = "UPDATE R2000 SET RType='' ";

$result= mysql_query($query);

$query1 = " SELECT * FROM R2000 WHERE RType IS NULL" ;

etc ...etc.... (I omitted the error checking stuff from this posting for brevity's sake).

Thanks !

Reply With Quote
  #2  
Old April 22nd, 2000, 08:56 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
You are not defining a WHERE clause in your update. I believe that is required in update statements.

TAICBW

Reply With Quote
  #3  
Old April 22nd, 2000, 09:00 PM
rod k rod k is offline
Apprentice Deity
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jul 1999
Location: Niagara Falls (On the wrong side of the gorge)
Posts: 3,237 rod k User rank is Private First Class (20 - 50 Reputation Level)rod k User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 13
Send a message via AIM to rod k
RTFM, Rod. Yes, I was wrong, you don't need a where clause.

I'm assuming it WILL work in the opposite direction? i.e. that you can set it to an empty string on insert and then change to null?

Reply With Quote
  #4  
Old April 25th, 2000, 01:24 PM
jprophet jprophet is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 2 jprophet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No, actually that doesn't work either - it seems like I can't actually alter the value of a CHAR(0) field with a PHP MySQL query, which just doesn't sound right !

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > NULL vs. empty string in CHAR(0) field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT