Hey there if i have the following
insert into users (username) values ('troy') ;
and then straight after that i want to do
insert into customer (name,user_id) values ('troy','$id') ;
how do you get the id of the first insert statement (assuming we have a serial primary key) without doing a select statement in between. I mean the way i've bein doing it is gettin the last record in the table. But that is not safe.
Anyone have any better ways?
Cheers
Troy
insert into users (username) values ('troy') ;
and then straight after that i want to do
insert into customer (name,user_id) values ('troy','$id') ;
how do you get the id of the first insert statement (assuming we have a serial primary key) without doing a select statement in between. I mean the way i've bein doing it is gettin the last record in the table. But that is not safe.
Anyone have any better ways?
Cheers
Troy