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
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.
"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
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
[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
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
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
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)
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
Pgsql support autoincremental field like mysql ?
Thanks
10 matches
Mail list logo