php - MySQL odd and even auto-incremented IDs -
i have 2 tables in mysql. both tables store same thing, 1 table stores data not final (will later changed) , 1 table stores final data.
notfinal table ---------------------- id parentid value 1 2 0.5 2 2 0.3 .
final table ---------------------- id parentid value 1 1 0.5 2 2 0.3 3 2 0.4 now, thing want select id of entires have parentid = 2, doesn't matter table. if select join 1,2,2,3 in case id 2 duplicate (id 2 has parentid 2 in both first , second table).
so, actual problem don't know table id came from. fix problem thinking in non-final table have odd ids , in final table have even ids. doing never result in conflicting ids , know id came table.
can set mysql auto-increment ids in first table odd , in second 1 even?
so tables this:
notfinal table ---------------------- id parentid value 1 2 0.5 3 2 0.3 .
final table ---------------------- id parentid value 2 1 0.5 4 2 0.3 6 2 0.4
you can use configuration options auto_increment_increment , auto_increment_offset mentioned in mysql manual.
their primary use replication, can changed in each session, can use them purpose. set them need before manipulating either of these 2 tables (change session variables, not global ones).
Comments
Post a Comment