New: Can someone tell me if you see an error in this code?

Discussion in 'MySQL' started by Mitchell, Jun 30, 2009.

  1. #1
    I am trying to create an sql file and import it into a data base. I get an error #1064. The MySQL manual provides no meaningful information as to what this means.

    Can someone tell me what is wrong with my code and maybe what book if any you recommend I learn from? Thanks.


    CREATE TABLE IF NOT EXISTS `xhtml_table02` (
    'the_id' int(10) unsigned NOT NULL,
    `filename` blob NOT NULL,
    PRIMARY KEY (`the_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=2 ;

    INSERT INTO `xhtml_table02` (`the_id`, 'filename') VALUES
    (1, 'ncncncncncncn');
     
    Mitchell, Jun 30, 2009 IP
  2. Goramba

    Goramba Peon

    Messages:
    128
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    CREATE TABLE IF NOT EXISTS xhtml_table02(
    the_id int(10) unsigned NOT NULL auto_increment key,
    filename blob not null) engine=myisam auto_increment=2
     
    Goramba, Jun 30, 2009 IP
  3. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I will give it a try. Thanks.
     
    Mitchell, Jun 30, 2009 IP
  4. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I am still getting the same error. Maybe if I post the error message it will be clearer what the problem might be.

    Error

    SQL query:

    INSERT INTO `xhtml_table02` ( `the_id` , `filename` )
    VALUES ( 1, `ncncncncncncn` ) ;

    MySQL said: Documentation
    #1054 - Unknown column 'ncncncncncncn' in 'field list'
     
    Mitchell, Jun 30, 2009 IP
  5. shaibibutt

    shaibibutt Member

    Messages:
    606
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    35
    #5
    try it as

    ----
    CREATE TABLE IF NOT EXISTS xhtml_table02 (
    the_id int(10) unsigned NOT NULL,
    filename char (40) NOT NULL,
    PRIMARY KEY (the_id)
    ) TYPE=MyISAM AUTO_INCREMENT=2 ;

    --
    INSERT INTO xhtml_table02 VALUES ( 1, `ncncncncncncn`) ;

    I hope it'l work on ur side now
     
    shaibibutt, Jul 1, 2009 IP
  6. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ` is only to surround table and column names.

    Use the apostrophe ' to surround data.

    So instead of
    INSERT INTO xhtml_table02 VALUES ( 1, `ncncncncncncn`) ;

    This is why you are getting Unknown column 'ncncncncncncn' in 'field list' because it thinks that ncncncncncncn is a field when you use `

    Use...
    INSERT INTO xhtml_table02 VALUES ( 1, 'ncncncncncncn') ;
     
    nyxano, Jul 1, 2009 IP
  7. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Thanks for all of your help.

    I plan on replacing (cncncncnc) with html data, thus is why I am using blob instead of char (40) or some other type. Maybe I should have pointed that out in the first place. I will however probably learn something from the rest of your suggestion.

    It looks like your apostrophe suggestion worked.

    Thanks a bunch.
     
    Mitchell, Jul 1, 2009 IP
  8. nyxano

    nyxano Peon

    Messages:
    417
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Regardless of what the field data type is, you still use an apostrophe to surround it. Apostrophies are for data, ` is for field names.
     
    nyxano, Jul 2, 2009 IP
  9. Mitchell

    Mitchell Peon

    Messages:
    204
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thanks nyxano.

    I copied what you said to my hard drive so I can refer to it in the future.
     
    Mitchell, Jul 2, 2009 IP
  10. alfa_375

    alfa_375 Active Member

    Messages:
    445
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #10

    How does the blog type works, can you explaing little bit more on it.
     
    alfa_375, Jul 5, 2009 IP