MySQL return values
am 24.10.2005 12:20:45 von feudalac
I have to insert a value into a table and with the new ID i have to
update some other tables.
is there a way to do it like:
insert into table (fields) values(...) and return id of new record
update table set field=id of new record where id=number
for now i
insert into table
read last record from table (order by id desc limit 1)
and then undate other tables with the id given...
something to reduce the number of queryes...
thanks
Re: MySQL return values
am 24.10.2005 12:27:39 von Kimmo Laine
"Feudalac!" wrote in message
news:djichr$du3$1@ss405.t-com.hr...
>I have to insert a value into a table and with the new ID i have to
> update some other tables.
>
> is there a way to do it like:
> insert into table (fields) values(...) and return id of new record
>
> update table set field=id of new record where id=number
>
>
> for now i
> insert into table
> read last record from table (order by id desc limit 1)
> and then undate other tables with the id given...
>
> something to reduce the number of queryes...
php has a built-in function for this: mysql_insert_id().
see www.php.net/mysql_insert_id for details.
--
Welcome to Usenet! Please leave tolerance, understanding
and intelligence at the door. They aren't welcome here.
antaatulla.sikanautaa@gmail.com.NOSPAM.invalid
Re: MySQL return values
am 24.10.2005 14:59:14 von feudalac
Kimmo Laine wrote:
> "Feudalac!" wrote in message
> news:djichr$du3$1@ss405.t-com.hr...
> > I have to insert a value into a table and with the new ID i have to
> > update some other tables.
> >
> > is there a way to do it like:
> > insert into table (fields) values(...) and return id of new record
> >
> > update table set field=id of new record where id=number
> >
> >
> > for now i
> > insert into table
> > read last record from table (order by id desc limit 1)
> > and then undate other tables with the id given...
> >
> > something to reduce the number of queryes...
>
>
> php has a built-in function for this: mysql_insert_id().
> see www.php.net/mysql_insert_id for details.
thanks