Combine 2 table results into one?

I have tables that start like this:

table_a
table_b
table_c

Now

With first query I wanna fetch the table prefix like a,b,c etc. and then somehow apply that to the table name in query!

How to make this work???

SELECT * 
FROM motor_ (SELECT c.`name` FROM `names` AS `c` 
		WHERE c.`name` = 'espana')  WHERE 1

no can do, you’ll need to redesign your tables

or else keep on doing two queries

OK thanks buddy gonna use 2 queries.

What you really need to do is learn Database Normalization and then fix your database or you will forever be hacking your way through the application.

The Database is the foundation of all the code you will ever write against it. If the Database is wrong then all the code you write to interact with it will be “wrong”.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.