Is there any command to do a select on all tables in a mysql database? Type I have multiple tables in my database with miscellaneous content. I need a way for a user to search for a keyword in all tables.
Is there any command to do a select on all tables in a mysql database? Type I have multiple tables in my database with miscellaneous content. I need a way for a user to search for a keyword in all tables.
I made an example ... I created 3 totally different tables and put in each one 1 common content (my name, Walmir). Here's the data I've entered for example:
Foryoutoqueryinthese3distincttables,youcoulddothefollowing:
SELECT'tb_a'asref,a.nomeasresultFROMtb_aaWHEREa.nomeLIKE'%Walmir%'UNIONSELECT'tb_b'asref,b.descricaoasresultFROMtb_bbWHEREb.descricaoLIKE'%Walmir%'UNIONSELECT'tb_c'asref,c.conteudoasresultFROMtb_ccWHEREc.conteudoLIKE'%Walmir%'
Result:
Please see if it solves what you need. Anything leaves a comment that I modify this answer. Okay?
The simple answer is: there is NO command to do 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.