complicated inserts

Posted by liysd on Stack Overflow See other posts from Stack Overflow or by liysd
Published on 2010-06-12T13:19:36Z Indexed on 2010/06/12 13:42 UTC
Read the original article Hit count: 357

Filed under:
|
|

I have to do something like this

insert into object (name, value, first_node) values ('some_name', 123, 0)
@id = mysql_last_insert_id()
insert nodes (name, object_id) values ('node_name',@id)
@id2 = mysql_last_insert_id()
update object set first_node=@id2 where id=@id

Is it possible to make it simpler? What if I want to insert more pairs (object, node) with resonable efficency?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql