0

I have a website that has been successfully migrated but still some of the urls still point to the previous address. I updated my databse (phpmyadmin) using the following commands:

UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');

UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');

How can I search all the tables for references to the old address? thank you

  • have you had a look here? similiar problem but on TSQL https://stackoverflow.com/questions/709120/how-to-search-for-one-value-in-any-column-of-any-table-inside-one-ms-sql-databas – Esteban P. Jul 10 '17 at 14:11
  • @EstebanP. yes but this solution does not make sense to me. I was hopping for a simple command that I can put in the sql propm –  Jul 10 '17 at 14:17
  • @humham in that example it's simply getting all the names of all the possible tables dynamically (from the database's master list of tables, which itself is held in a table), then looping through them to search all the possible (text) columns. The only other alternative without using dynamic SQL is to simply write out all the possible queries yourself and then run them. In MySQL dynamic SQL is achieved using Prepared Statements, which you can google. – ADyson Jul 10 '17 at 14:23

1 Answers1

-3

are you using sql server ? there you could try:

select 'select '+c.name +' from '+ t.name +' where ' +c.name  + ' like ''%wwww.oldurl%'''
from sys.tables t 
  join sys.all_columns c 
    on c.object_id=t.object_id

it gives you a bunch of selects, where you could look in which table/columns athere is the old url ... and then update it

ADyson
  • 57,178
  • 14
  • 51
  • 63
mike14021
  • 1
  • 1