There is a table A(id, b_id, value) in which the b_id column refers to the id column of table B(id, value) . Previously, value was stored in table A , but now table B added (it is still empty) where you need to insert records and transfer data. I mean that I will do something like insert into B (value) select value from A and thus for each record from table A will create an entry in table B , but I don’t know how to record A.b_id link to the created record . Unless to fulfill request from somewhere from php for example and insert line by line into table B and update table A Is it possible to do this from mysql somehow?
|
set @index = 0; update A set @index = @index + 1 set b_id = @index;set @index = 0; update A set @index = @index + 1 set b_id = @index;- PECHAPTERset @index = 0; update A set b_id = (@index := @index + 1);set @index = 0; update A set b_id = (@index := @index + 1);. Thank! - PECHAPTER