Results 1 to 4 of 4
Thread: Question about Mysql database
-
11-27-2004, 07:50 PM #1Junior Guru
- Join Date
- Feb 2004
- Posts
- 217
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
-
11-27-2004, 08:19 PM #2WHT Addict
- 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]
-
11-27-2004, 09:39 PM #3Junior Guru
- Join Date
- Feb 2004
- Posts
- 217
Worked nicely, Thanks!!
Thanks, Kevin
-
11-28-2004, 03:35 AM #4Web Hosting Master
- 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