question over NULL error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poolboi
    New Member
    • Jan 2008
    • 170

    question over NULL error

    hi,
    i'm new to mysql and am learning all by myself by tutorial
    and i came across a problem

    below is the code i'm using;

    [CODE=mysql]
    CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
    species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
    LOAD DATA LOCAL INFILE '/path/pet.txt' INTO TABLE pet;
    [/CODE]

    and my my text file is :
    [CODE=text]
    Fluffy Harold cat f 1993-02-04 \N
    Claws Gwen cat m 1994-03-17 \N
    Buffy Harold dog f 1989-05-13 \N
    Fang Benny dog m 1990-08-27 \N
    Bowser Diane dog m 1979-08-31 1995-07-29
    Chirpy Gwen bird f 1998-09-11 \N
    Whistler Gwen bird \N 1997-12-09 \N
    Slim Benny snake m 1996-04-29 \N
    [/CODE]

    it's been explained that \N give me null but then when i exccute SELECT * FROM pet;

    the results i got was:
    Code:
    Fluffy	Harold	cat	f	1993-02-04	0000-00-00   
    Claws 	Gwen 	cat 	m 	1994-03-17	NULL	   
    Buffy 	Harold 	dog 	f 	1989-05-13	0000-00-00 
    Fang 	Benny 	dog 	m 	1990-08-27	0000-00-00   
    Bowser 	Diane 	dog 	m 	1979-08-31 	1995-07-29 
    Chirpy 	Gwen 	bird	f 	1998-09-11	0000-00-00   
    Whistler	Gwen 	bird	NULL	1997-12-09	0000-00-00
     Slim 	Benny 	snake 	m 	1996-04-29	0000-00-00
    any idea why some appear as null only??
    and the rest as 0000-00-00
    and also the warnings shown were like data at the last column ws truncated
    and that row 2 and 7 contains more inputs than the input columns
    Last edited by ronverdonk; Mar 25 '08, 09:45 AM. Reason: extra code tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The number of spaces preceding to \N might count .

    Comment

    Working...