Search text in fields in every table of a MySQL database

前端 未结 24 1921
梦谈多话
梦谈多话 2020-11-22 06:23

I want to search in all fields from all tables of a MySQL database a given string, possibly using syntax as:

SELECT * FROM * WHERE * LIKE \'%stuff%\'
         


        
24条回答
  •  温柔的废话
    2020-11-22 06:37

    You could use

    SHOW TABLES;
    

    Then get the columns in those tables (in a loop) with

    SHOW COLUMNS FROM table;
    

    and then with that info create many many queries which you can also UNION if you need.

    But this is extremely heavy on the database. Specially if you are doing a LIKE search.

提交回复
热议问题