Given the example table;
CREATE TABLE mytable
(
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
desc VARCHAR(30) NOT NULL
);
How do I insert records at the command line to utilise the auto_increment feature of MySQL.
i.e. INSERT INTO mytable VALUES(?,"description");
Any assistance will be greatly appreciated.
-Dickey
MySQL:insert at mysql cmd line when using auto_increment
Moderator: General Moderators
answering my own post
INSERT INTO mytable VALUES(id,"description");
- Bill H
- DevNet Resident
- Posts: 1136
- Joined: Sat Jun 01, 2002 10:16 am
- Location: San Diego CA
- Contact:
for readability, I always insert zero
Code: Select all
$Query = "INSERT INTO Inst (id, Name, Abbr) VALUES (0, '$Name','$Abbr')";This is the way I do it
Hope this helps
Code: Select all
INSERT INTO mytable VALUES('','description');