List:General Discussion« Previous MessageNext Message »
From:Christian Mack Date:July 27 1999 7:41pm
Subject:Re: dynamic table
View as plain text  
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

Thread
dynamic tableStephen Uczekaj27 Jul
  • Re: dynamic tableMartin Ramsch27 Jul
  • Re: dynamic tableChristian Mack27 Jul