| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Chris W | Date: | November 25 2007 7:09pm |
| Subject: | Re: Incrementing a "Private" Integer Space | ||
| View as plain text | |||
Stut wrote: > > insert into test1 set p = 2, q = (select max(q) + 1 from test1 as tmp > where p = 2) > > Probably not very efficient, but it works. > > -Stut > Auto increment is much easier to do. If your primary key is made up of two fields and one of them is Auto Increment, then it will have the desired behavior, just do this experiment and see.... CREATE TABLE `t` ( `p` int(10) unsigned NOT NULL default '0', `q` int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (`p`,`q`) ) ; INSERT INTO `t` (`p`,`q`) VALUES (1,NULL), (1,NULL), (1,NULL), (2,NULL), (2,NULL), (2,NULL), (2,NULL), (2,NULL), (3,NULL), (3,NULL); -- Chris W KE5GIX "Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm" Ham Radio Repeater Database. http://hrrdb.com
| Thread | ||
|---|---|---|
| • Incrementing a "Private" Integer Space | David T. Ashley | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | Chris W | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | Stut | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | David T. Ashley | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | Stut | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | Chris W | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | David T. Ashley | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | Chris W | 25 Nov |
| • RE: Incrementing a "Private" Integer Space | Martin Gainty | 25 Nov |
| • Re: Incrementing a "Private" Integer Space | David T. Ashley | 25 Nov |
