This isn't always desirable, or even possible. I once designed a database to hold characteristics for a series of 70 different tests. There were about 50 different characteristics used in various combinations for each test. Each characteristic could be one of many values. So the characteristics tables all looked like this:

id, name, value

And the test tables looked like this:

id, name, value

And the mapping of characteristics to test looked like this:

test_id, characteristic_id

This is actually a gross oversimplification, but you get the idea. Displaying test results typically required joining 30-40 tables together, but since each characteristic table was small (10-15 entries), performance was acceptable.

So do as John Nichel first suggested, and do this:

select c1.id as characteristic1_id, c2.id as characteristic2_id from characteristic1 c1, characteristic2 c2 ....etc.

cheers,

Travis

John W. Holmes wrote:
Dave Carrera wrote:

Hi List,

How do I select data from 24 table in my database.

Each one is identical in structure layout being

Id,name,list


The first thing you need to do is reorganize your database schema and put all of this into one table. You can see what a pain it is having 24 similar tables already and it's only going to get worse.

You could probably use a UNION to join all of the tables together in your query, but I doubt it's going to very efficient. You can't select from a list of tables the way you're trying to, though.

Last option is putting your query in a loop and executing it 24 different times, but you _really_ need to just fix the database structure now.


-- Travis Low <mailto:[EMAIL PROTECTED]> <http://www.dawnstar.com>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to