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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

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

android - How to create dynamically Fragment pager adapter -