Select * FROM all tables? MySQL

I've got a database I'm working with where there's an ever expanding number of tables - associated by a specific row (let's call it "blah").

Instead of doing joins - is there syntax for me to basically say...

"SELECT * FROM all tables
WHERE blah = 'whatever'

?
LVL 2
erzoolanderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike EghtebasDatabase and Application DeveloperCommented:
assuming blah is a column name and string, use:

SELECT blah FROM Table1
WHERE blah = 'whatever'

will work.

If there another table with field blah, then use:

SELECT blah FROM Table1 Union
SELECT blah FROM Table2
WHERE blah = 'whatever'

and so on.

There is a way to query system tables to get the names and the [blah]s exist in the database and then design a proc to search for the information you need.

Mike
0
Bitaseme MboeDeveloperCommented:
This was done in SQL Server but...
SELECT * FROM sys.tables ...

Open in new window

should do the trick for you. You may have to modify the syntax to fit MY SQL.
0
Ray PaseurCommented:
I believe you can do something like this.  It would be easy to test.  You may have to provide aliases for the column names to eliminate ambiguity.  This is not a query you would want to run in a production environment!

SELECT * FROM table1, table2, table3...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.