Re: [GENERAL] Autoincremental value

2004-08-18 Thread Scott Marlowe
On Tue, 2004-08-17 at 12:22, Pierre-FrÃdÃric Caillaud wrote: > Suppose your table is like : > > key1key2 > 1 1 > 1 2 > 2 1 > > To get the next value to insert for key1=1 you can do this : > > SELECT key2 FROM ... WHERE key1=1 ORDER

Re: [GENERAL] Autoincremental value

2004-08-17 Thread Pierre-Frédéric Caillaud
Suppose your table is like : key1key2 1 1 1 2 2 1 To get the next value to insert for key1=1 you can do this : SELECT key2 FROM ... WHERE key1=1 ORDER BY key2 DESC LIMIT 1 Of course a UNIQUE INDEX on key1, key2 helps.

Re: [GENERAL] Autoincremental value

2004-08-13 Thread gnari
"Josué Maldonado" <[EMAIL PROTECTED]> wrote: > > El 13/08/2004 10:50 AM, [EMAIL PROTECTED] en su mensaje > escribio: > > ... > > insert into table1 (field1) values (1); > > insert into table1 (field1) values (1); > > insert into table1 (field1) values (2); > > > > and then select * from table1, you

Re: [GENERAL] Autoincremental value

2004-08-13 Thread Ben
Yep, use the serial datatype. And then use the helpful documention. :) http://www.postgresql.org/docs/7.4/static/datatype.html#DATATYPE-SERIAL http://www.postgresql.org/docs/faqs/FAQ.html#4.15.2 On Fri, 13 Aug 2004 [EMAIL PROTECTED] wrote: > Hi I'm a newbie in postgresql, I came from MSSQL, MySQ

Re: [GENERAL] Autoincremental value

2004-08-13 Thread Mage
[EMAIL PROTECTED] wrote: when insert rows: insert into table1 (field1) values (1); insert into table1 (field1) values (1); insert into table1 (field1) values (2); and then select * from table1, you get: field1| field2 --+--- 1 | 1 1 | 2 2 | 1 --+--- Do you mean: field

Re: [GENERAL] Autoincremental value

2004-08-13 Thread Bruno Wolff III
On Fri, Aug 13, 2004 at 13:50:48 -0300, [EMAIL PROTECTED] wrote: > Hi I'm a newbie in postgresql, I came from MSSQL, MySQL and now > I'm testing postgres. > In mysql there is a way to make a second autoincrement field, just: Use serial for the type. You probably want to read up on sequences and

Re: [GENERAL] Autoincremental value

2004-08-13 Thread Josué Maldonado
Hello, El 13/08/2004 10:50 AM, [EMAIL PROTECTED] en su mensaje escribio: Hi I'm a newbie in postgresql, I came from MSSQL, MySQL and now I'm testing postgres. In mysql there is a way to make a second autoincrement field, just: create table table1 (field1 integer, field2 integer autoincrement, prim

[GENERAL] Autoincremental value

2004-08-13 Thread adburne
Hi I'm a newbie in postgresql, I came from MSSQL, MySQL and now I'm testing postgres. In mysql there is a way to make a second autoincrement field, just: create table table1 (field1 integer, field2 integer autoincrement, primary key (field1,field2)) when insert rows: insert into table1 (field1)

Re: [GENERAL] Autoincremental

1999-08-15 Thread Charles Tassell
Yes, it's called "serial" IE: create table my table ( ndx serial, nametext ); "serial" is just a shortcut that creates a "sequence" (a type that is basically a counter) an sets the ndx field to be an int default nextval('sequence_name') Read the FAQ for a better explan

[GENERAL] Autoincremental

1999-08-15 Thread Matteo Colombo
Pgsql support autoincremental field like mysql ? Thanks