| | |
MySQL Multiple Table Search
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2005
Posts: 1
Reputation:
Solved Threads: 0
I have a MySQL database design which consists of several tables that are identical in structure, but contain different sets of data (each table is assigned to a specific group of people). This is because each table might grow to several tens of thousands entries, and with a prospect of up to a hundred (or more) groups, I wanted to keep things small for each group.
There is a SINGLE case where I'd need to perform a search on an index field accross ALL tables. JOINS haven't worked, and the only thing I've managed to get to work was a UNION. But a UNION accross a hundred tables, i.e.
will get VERY expensive, VERY soon. The syntax
obviously doesn't work because the field id is not unique, and if I change the syntax to
then the result I get is not what I was looking for (the results are joined).
Does anybody know a better way of searching accross multiple identical tables on a single field?
There is a SINGLE case where I'd need to perform a search on an index field accross ALL tables. JOINS haven't worked, and the only thing I've managed to get to work was a UNION. But a UNION accross a hundred tables, i.e.
MySQL Syntax (Toggle Plain Text)
(SELECT * FROM a WHERE id=1) UNION (SELECT * FROM b WHERE id=1) UNION (SELECT * FROM c WHERE id=1) UNION ... etc
MySQL Syntax (Toggle Plain Text)
SELECT * FROM a,b,c WHERE id=1
MySQL Syntax (Toggle Plain Text)
SELECT * FROM a,b,c WHERE a.id=1 OR b.id=1 OR c.id=1
Does anybody know a better way of searching accross multiple identical tables on a single field?
![]() |
Similar Threads
- Traffic Exchange (PHP)
- MySql multiple table query problem.... (MySQL)
Other Threads in the MySQL Forum
- Previous Thread: Creating New Columns From Calucations
- Next Thread: some help in importing and exporting data
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api aws bizspark breathalyzer changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





