Change URL of all MySQL DBMS tables with PHP

-1

I have a MySQL DBMS with multiple tables, I tried unsuccessfully doing a routine, I need to change all the URLs of all the tables to another URL.

Ex: link for link

    
asked by anonymous 12.04.2018 / 22:01

1 answer

1

You can use the information_schema.columns table to extract the list of columns and tables and mount the update statements to run individually. Example:

SELECT
    CONCAT('UPDATE ', table_name, ' SET ', column_name, ' = REPLACE(', column_name, ', ''xxx'', ''yyy'');')
FROM
    information_schema.columns
WHERE
    table_schema = '<SEU BANCO AQUI>'
    AND data_type IN ('char, ''varchar', 'text')
ORDER BY
    table_name,
    ordinal_position;
    
12.04.2018 / 22:10