Stephen Uczekaj wrote:
>
> Can anyone tell me how to insert a new row into a table which contains only one
> field defined as follows:
>
> mysql> create table abstract(ID int not null auto_increment primary key);
> Query OK, 0 rows affected (0.07 sec)
>
> mysql> describe abstract;
> +-------+---------+------+-----+---------+----------------+
> | Field | Type | Null | Key | Default | Extra |
> +-------+---------+------+-----+---------+----------------+
> | ID | int(11) | | PRI | 0 | auto_increment |
> +-------+---------+------+-----+---------+----------------+
> 1 row in set (0.01 sec)
>
> I will be adding and removing columns dynamically, but I need to create the row
> first and obtain the ID. Any ideas...
>
> steve u.
> boeing phantom works
Hi Steve
That's an easy one:
INSERT INTO abstract VALUES (NULL);
or:
INSERT INTO abstract VALUES (0);
And you can get the last inserted auto_increment value by:
SELECT LAST_INSERT_ID();
Tschau
Christian