Page 1 of 1

transfer sql "table1" to "table2"

Posted: Wed May 28, 2008 9:40 pm
by stevengoh
hi

Can I check with all of you how to transfer sql "table1" pid row number 2 to "table2" pid highest row. Like say my "table2" highest row currently at pid 11, so it will transfer to number 12.

thank

Re: transfer sql "table1" to "table2"

Posted: Thu May 29, 2008 4:28 am
by panic!
try the databases forum.

Re: transfer sql "table1" to "table2"

Posted: Thu May 29, 2008 6:11 am
by Rovas
Use mysql_insert_id to retrieve the last id. Be careful it only works good in no race environment (i.e. multiple users updating the same tables) and must one auto increment column.

Re: transfer sql "table1" to "table2"

Posted: Thu May 29, 2008 10:00 am
by pickle
Moved to Databases.

mysql_insert_id() works fine in race conditions, because that function returns the last inserted ID [em]for your connection[/em] not for the table. If you've got 20 people updating the table & the all call mysql_insert_id(), they'll all get 20 different numbers.

Re: transfer sql "table1" to "table2"

Posted: Thu May 29, 2008 11:27 am
by stevengoh
thank

but I think that is not the solution bec I just want to transfer one row from table1 to table2 in mysql . Use something like trigger is it??

pls help