0
Is there a command to select all tables in a mysql database? Like I have several tables in my database with diverse content. I need a way that a user can search for a keyword in all tables.
0
Is there a command to select all tables in a mysql database? Like I have several tables in my database with diverse content. I need a way that a user can search for a keyword in all tables.
2
I made an example... I created 3 totally different tables and put in each one 1 content in common (my name, Walmir). See the data I entered for example:
To perform the query in these 3 different tables, you could do it as follows:
SELECT 'tb_a' as ref, a.nome as result FROM tb_a a WHERE a.nome LIKE '%Walmir%'
UNION
SELECT 'tb_b' as ref, b.descricao as result FROM tb_b b WHERE b.descricao LIKE '%Walmir%'
UNION
SELECT 'tb_c' as ref, c.conteudo as result FROM tb_c c WHERE c.conteudo LIKE '%Walmir%'
Upshot:
Please see if it solves what you need. Anything leaves a comment that I modify this answer. Ok?
1
The simple answer is: there is no ONE command that does this. You will have to implement multiple selects and join them, or create a script or stored Procedure to achieve this, using the information_schema table.
It is important to be aware that this type of search can compromise your bank’s performance.
If you have phpmyadmin installed you can use the search by selecting the database instead of the tables.
0
SELECT * FROM information_schema.Tables WHERE table_schema = 'bank name';
But aeh lists only the name of the columns. I need to do something like this: select * from banco_de_dados_todo WHERE * = word_key
Put an AND table_name = "$TABLE_NAME";
Browser other questions tagged sql select
You are not signed in. Login or sign up in order to post.
very good. I understood the use of UNION that I did not know how to use. I need to implement a search on a website, but searching multiple tables using a keyword. But I realized that this will generate a problem that is presenting the data to the user. But thank you.
– Flávio Kowalske
I’m glad you can help. ;)
– Walmir Silva