mysql - SQL update from one Databse to another based on a Title match -


i finished migrating wordpress database, went right.

until realise got serious issue posts id changed after processes

and i’m using posts id on urls , want keep using don’t lose old links.

i still have both databases (old & new) , want know how can update id old 1 new 1 matching title?

something like:

update newbase table id oldbase table id oldbase title = newbase title 

:p :d

thanks help.

translating pseudo-code sql should trick:

update newdb.tablename n inner join olddb.tablename o on n.title=o.title set n.id=o.id; 

caveat

you might run duplicate id values, might want move them first

select @oldmax:=max(id) olddb.tablename; select @newmax:=max(id) newdb.tablename; update newdb.tablename set id=id+@oldmax+@newmax; 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -