Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2009
    Posts
    33

    Unanswered: MYSQL Create Table Syntax

    can someone point out what's wrong with the following syntax?
    Code:
    DROP TABLE IF EXISTS `jos_keyword_stats`;
     
    CREATE TABLE `jos_keyword_stats` (
      `Keyword` text,
      `Date` date NOT NULL,
      'Time' time,
      'Destination' mediumtext,
      'Location' mediumtext,
      'UserIP' text,
      'UserAgent' text,
      'id' int(11) NOT NULL auto_increment,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
    thanks

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    try it like this --
    Code:
    CREATE TABLE jos_keyword_stats 
    ( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT 
    , Keyword      VARCHAR(99) NOT NULL
    , MyDateTime   DATETIME    NOT NULL
    , Destination  VARCHAR(99)
    , Location     VARCHAR(99)
    , UserIP       VARCHAR(15)
    , UserAgent    VARCHAR(99)
    ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;
    your problem was that you had several strings in there (delimited by single quotes) instead of column names (optionally delimited by backticks)

    i've also made some suggested improvements
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •