简体   繁体   中英

Wildcard SQL Query to search for specific text & replace

I'm trying to make an extremely wildcarded SQL query to find a specific URL across multiple sites (via phpMyAdmin) and replace them.

I've started off with the following, however it apparently isn't a valid SQL Query:

SELECT * FROM *.* WHERE * LIKE '%https://website.com/er01%'

I'm essentially trying to look in every single database, every single table, every single column. Once I've checked them I want to create a query to replace the URL with a new one (The URL would need to be replaced within the middle of a value as they're normally within the page content)

I am a novice with SQL so it's likely to be something obvious but I can't find a way to do what I want anywhere online.

You need to run

show databases;

For each database, run

show tables;

For each table, run

desc <tablename>

And for each column, run

select * from databasename.tablename where columnname like '%https://website.com/er01%';

If there are too many possibilities to do so, then consider generating the queries.

And if you need all results, then consider unioning them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM