tc101
May 12th, 2007, 12:25 PM
Suppose I create this table
CREATE TABLE Person2
(
PKey INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (PKey),
FirstName varchar(20),
LastName varchar(20),
Address varchar (20),
Age int
)
and I want to insert a row and set the primary key to the next available integer. Do I have to list all the field names, like this
INSERT INTO Person2 (FirstName,LastName,Address,Age) VALUES("Bill","Smith","box 7",25)
or is there a shorter way to do it, without listing the field names, something like this, although this doesn't work:
INSERT INTO Person2 VALUES(auto,"bob","blow","East Avenue",22)
CREATE TABLE Person2
(
PKey INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY (PKey),
FirstName varchar(20),
LastName varchar(20),
Address varchar (20),
Age int
)
and I want to insert a row and set the primary key to the next available integer. Do I have to list all the field names, like this
INSERT INTO Person2 (FirstName,LastName,Address,Age) VALUES("Bill","Smith","box 7",25)
or is there a shorter way to do it, without listing the field names, something like this, although this doesn't work:
INSERT INTO Person2 VALUES(auto,"bob","blow","East Avenue",22)