- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerateQueriesToFindText.sql
More file actions
Latest commit
24 lines (19 loc) · 788 Bytes
/
Copy pathgenerateQueriesToFindText.sql
File metadata and controls
24 lines (19 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- +------------------------------------------------------
-- + Generates a list of queries to run to find a specified search term
-- + Author: Simon Rogers
-- + Date: 7th January 2016
-- + SQL: mysql
-- +------------------------------------------------------
SET @searchTerm ='%<searchTerm>%';
CREATE TEMPORARY TABLE search (
id int(11) NOT NULL AUTO_INCREMENT,
search varchar(1020) NOT NULL,
PRIMARY KEY(id)
);
INSERT INTO search (search)
SELECT concat('SELECT * FROM ', table_name, ' WHERE `', column_name, '` like \'%',@searchTerm,'%\';') as`SearchTerm`
FROMinformation_schema.columns
WHERE data_type in ('char', 'varchar', 'longtext', 'mediumtext', 'text', 'tinytext', 'set')
and table_schema !='information_schema';
SELECT search FROM search;
DROP TEMPORARY TABLE search;