Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Location
    UK
    Posts
    12

    Unanswered: this is an easy one?

    This must be simple but I keep getting an error when trying to create the following table. I've been on it 30 mins and it's driving me mad! Please help?

    Error

    SQL-query :

    CREATE TABLE `product` (

    `UPC` TEXT( 20 ) NOT NULL ,
    `ShortDescription` TEXT( 50 ) NOT NULL ,
    `LongDescription` LONGTEXT( 500 ) NOT NULL ,
    `Price` FLOAT( 7 ) NOT NULL ,
    `MainCategory` TEXT( 50 ) NOT NULL ,
    `SubCategory` TEXT( 50 ) NOT NULL ,
    `ImageID` TEXT( 50 ) NOT NULL ,
    `Supplier` TEXT( 50 ) NOT NULL ,
    `SearchRef` TEXT( 100 ) NOT NULL ,
    PRIMARY KEY ( `UPC` )
    )

    MySQL said:


    #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 '( 20 ) NOT NULL ,
    `ShortDescription` TEXT( 50 ) NOT NULL

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    did you actually check the manual as suggested?

    neither TEXT nor LONGTEXT takes a length parameter

    you're thinking of VARCHAR

    change TEXT(n) to VARCHAR(n) where n is less than or equal to 255

    if you need a column to hold more than 255 bytes, then use TEXT (with no length parameter) which will give you a 65K field
    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
  •