sql - Select from hundreds of tables at once (.mdb) -
We have an .mdb file with hundreds of tables: Lesson 1, Lesson 2, Lesson 3, Lesson 4, etc. All tables have the same structure:
text < N & gt; ---------------- Description of Slide_ID name Created Status / updated by data_ updated_by
Will the SQL statement generate such a result? :
| Table_name | Slide_id | Name | | ----------------------- | ------------------------- ------ | | Lesson 1 | 1 | Name for slide 1 of Lesson 1. | Lesson 1 | 2 | Name for Slide 2 of Lesson 1. | Lesson 2 | 1 | Name for Slide 1 of Lesson 2 | | Lesson 2 | 2 | Whatever. | Lesson 2 | 3 | Again |
etc.
There are hundreds of tables < P>
If the table names are known , you can create such a query: Selecton 'Lesson2', Slide_ID, Name, ... from Lesson2 union, 'Lesson3', 'slide_id, name', for everyone, selected as' SELECT 'Lesson1' as table_name, slide_ID, name, ... from Lesson 1. Lesson 3 from 'Lesson4', Slide_ID, Name, ... Lesson 5 from all Lesson 5, slide_id, Name, ... to Subm 5
Cursor Only Then Shyk If the number of tables is in constant flux, if not, should do the trick.
Hint: To generate the initial query, paste the name in Excel into the table, and use the formula to create "Unius All" of that table in the next table. Then log back directly into the copy. (Or make it dynamically by using a cursor, but copy / paste and a quick formula is easy, and you can save the excel file, like you can add tables in bulk, change the selected columns etc)
And, of course, the end solution, if possible, should strengthen the tables, and add a discriminatory area during the inquiry. Hook, if you have, it is easy to maintain hundreds of questions, drag the rows of each lesson (again Excel can be a simple batch-update tool), there should be similar structures compared to hundreds of text tables.
Comments
Post a Comment