Greetings,

Thank you Dahl and Xiaobo. Here it is working for all to see. I particularly like that it doesn't try to use a key again once it is deleted.


Joe.




mysql> use names;
Database changed
mysql> create table people ( id mediumint unsigned not null auto_increment,
    -> first char(20),
    -> last char(20),
    -> primary key (id) );
Query OK, 0 rows affected (0.20 sec)

mysql> describe people;
+-------+-----------------------+------+-----+--------- +----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------------------+------+-----+--------- +----------------+ | id | mediumint(8) unsigned | | PRI | NULL | auto_increment | | first | char(20) | YES | | NULL | | | last | char(20) | YES | | NULL | | +-------+-----------------------+------+-----+--------- +----------------+
3 rows in set (0.02 sec)

mysql> insert into people (first, last) values ("john", "smith");
Query OK, 1 row affected (0.00 sec)

mysql> insert into people (first, last) values ("bob", "jones");
Query OK, 1 row affected (0.13 sec)

mysql> insert into people (first, last) values ("brad", "pitt");
Query OK, 1 row affected (0.00 sec)

mysql> select * from people;
+----+-------+-------+
| id | first | last  |
+----+-------+-------+
|  1 | john  | smith |
|  2 | bob   | jones |
|  3 | brad  | pitt  |
+----+-------+-------+
3 rows in set (0.02 sec)

mysql> delete from people where last = 'smith';
Query OK, 1 row affected (0.00 sec)

mysql> select * from people;
+----+-------+-------+
| id | first | last  |
+----+-------+-------+
|  2 | bob   | jones |
|  3 | brad  | pitt  |
+----+-------+-------+
2 rows in set (0.00 sec)

mysql> insert into people (first, last) values ("john", "smith");
Query OK, 1 row affected (0.06 sec)

mysql> select * from people;
+----+-------+-------+
| id | first | last  |
+----+-------+-------+
|  4 | john  | smith |
|  2 | bob   | jones |
|  3 | brad  | pitt  |
+----+-------+-------+
3 rows in set (0.21 sec)

mysql>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to