SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help understanding error message

    I'm not terribly experienced with databases. Can someone tell me what's wrong with this query? I've included the error message below - I'm not sure what it's telling me or how I fix it.

    CREATE TABLE saClient(
    clientID INTEGER UNSIGNED NOT NULL ,
    firstName VARCHAR NOT NULL AUTO_INCREMENT ,
    middleName VARCHAR NULL ,
    lastName VARCHAR NULL ,
    address1 VARCHAR NULL ,
    address2 VARCHAR NULL ,
    city VARCHAR NULL ,
    state VARCHAR NULL ,
    zip VARCHAR NULL ,
    birthday VARCHAR NULL ,
    ssn VARCHAR NULL ,
    fax VARCHAR NULL ,
    email1 VARCHAR NULL ,
    email2 VARCHAR NULL ,
    phoneCell VARCHAR NULL ,
    phoneHome VARCHAR NULL ,
    phoneWork VARCHAR NULL ,
    phoneOther VARCHAR NULL ,
    emergContactName VARCHAR NULL ,
    emergContactPhone1 VARCHAR NULL ,
    emergContactPhone2 VARCHAR NULL ,
    emergContactRelationship VARCHAR NULL ,
    sex TINYINT UNSIGNED NULL ,
    notes TEXT NULL ,
    STATUS TINYINT UNSIGNED NULL ,
    PRIMARY KEY ( clientID )
    )

    MySQL said: Documentation
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL AUTO_INCREMENT,
    middleName VARCHAR NULL,
    lastName VARCHAR NULL,
    ' at line 3

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    697
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You need to specify a maximum lengths for the columns defined as varchar

    e.g.

    Code:
    phoneHome vachar(20)
    Also, auto_increment can not be defined for a varchar column, use integer or bigint.

  3. #3
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    574
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Worked like a charm.


Bookmarks

Posting Permissions

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