Search text in fields in every table of a MySQL database

前端 未结 24 1582
梦谈多话
梦谈多话 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:44

    I used Union to string together queries. Don't know if it's the most efficient way, but it works.

    SELECT * FROM table1 WHERE name LIKE '%Bob%' Union
    SELCET * FROM table2 WHERE name LIKE '%Bob%';
    

提交回复
热议问题