join tables SQL = problem = my tables are not normalized

JohnD

Registered User.
Local time
Today, 09:42
Joined
Oct 4, 2005
Messages
98
Okay - the other database is in the works and is going sloooow (the one that is being created with normalization).

Meanwhile, my other database that has no normalization I am having a problem running a query (now I know why its so important to have good structure).

To give you an idea on how bad this is...:o .....

3 tables - 94 fields to each table - each table has identicle fields, just different data. :eek:

Anyways, I have students in each table (each table is an Annual Report). I want to be able to run a simple query and combine all the students into one.

How would I achieve this?

Thank you!

And for all who are thinking about designing a database - READ READ READ and do some more reading on normalization!!!
 
Code:
SELECT Table1.Students
FROM Table1
UNION 
SELECT  Table2.Students
FROM Table2
UNION
Select  Table3.Students
FROM Table3

If you want to show duplicates change the UNION to UNION ALL
 
Another stupid thing that I did with this database is named fields and the table using spaces!

its giving me an error and I am assuming its because of the spaces but I do have one more question..

I have more then one field I want to pull from the tables, do I just use a comma to seperate the fields?

Code:
SELECT Table1.FirstName, Table1.LastName, Table1.AR
FROM Table1
UNION 
SELECT  Table2.FirstName, Table2.LastName, Table2.AR
FROM Table2
UNION
Select  Table3.FirstName, Table3.LastName, Table3.AR
FROM Table3

Thanks again!
 

Users who are viewing this thread

Back
Top Bottom