Results 1 to 4 of 4
  1. #1

    Question about Mysql database

    I am working on a db and trying to add the following tables:

    create table Users
    (
    UserID int(5) not null auto_increment,
    Name varchar(50) not null,
    Username varchar(50) not null,
    Password varchar(50) not null,
    Email varchar(50) not null,
    primary key (UserID)
    );

    create table Inventorytbl
    (
    PID int(5) not null auto_increment,
    Product tinytext not null,
    UnitPrice float(10,2) not null,
    Quantity tinytext not null,
    Description tinytext not null,
    DateAdded timestamp(14)
    );

    How ever I get this error:

    #1075 - Incorrect table definition; There can only be one auto column and it must be defined as a key

    I am using mysql 4.0.20-standard, rhe, and cPanel.
    Thanks, Kevin

  2. #2
    Join Date
    Nov 2004
    Location
    Santa Clara, CA
    Posts
    124
    create table Inventorytbl
    (
    PID int(5) not null auto_increment,
    Product tinytext not null,
    UnitPrice float(10,2) not null,
    Quantity tinytext not null,
    Description tinytext not null,
    DateAdded timestamp(14)
    );

    Should be:
    create table Inventorytbl
    (
    PID int(5) not null auto_increment,
    Product tinytext not null,
    UnitPrice float(10,2) not null,
    Quantity tinytext not null,
    Description tinytext not null,
    DateAdded timestamp(14),
    primary key(PID)
    );
    [url=http://www.calevans.com[/url]

  3. #3
    Worked nicely, Thanks!!
    Thanks, Kevin

  4. #4
    Join Date
    Jul 2003
    Location
    Kuwait
    Posts
    5,104
    The reason here is that you cannot have a field that is auto incremented and is not a key

Posting Permissions

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