so want import data database , goes this:
id, title, content
for first table, can export fine, id auto_increment, , want new database have unique ids, not copied insert. thing posts have category, is:
post, category
where post posts.id. now, want this:
insert new_db.posts (title, content) values select db1.title, db1.content old_db.posts db1
but want each of respective category categories table. i'm not sure if i'm explaining myself, hope so. thanks!
you haven't said category column going, if in same table can do:
insert new_db.posts (title, content, category) select db1.title, db1.content, c.category old_db.posts db1, old_db.categories c db1.id = c.post
if going have new id
auto incremented going need result (id) of initial insert
, use new insert
in categories table.
Comments
Post a Comment