Joining results from multiple queries.

lawsonium

Registered User.
Local time
Today, 23:54
Joined
Jul 6, 2006
Messages
40
Hi,

My SQL is fairly basic so excuse me if this is something simple.

This isn't my database, I am trying to create a report on someone else's and it's a poor structure (sound familiar :-).

If I have created two queries; one of which selects results on students from one table and the other selects results on students from a completely different table.
This means I have two Hi,

My SQL ability is fairly basic so excuse me if this is something simple.

This isn't my database, I am trying to create a report on someone else's and it's a poor structure (sound familiar :-).

If I have created two queries; one of which selects results on students from one table and the other selects results on students from a completely different table, how do I combine these results into one query so I can run a report on it?

To outline the situation, I have two different queries with identical data types but from two different tables. I need to query these two queries and (possibly) link in another ‘student information’ table so that I can display the results from both queries as if they all came from the same place.

The addition of the extra table in the final query would only be so I can add extra student data into the final report.

Hope this makes sense!

Thanks,

Matt.

different queries with identical data types
 
Try searching for help on UNION queries
 
I am doing my first ever UNION query now, getting there slowly I think.
Thanks very much for pointing me in the correct direction.

One question though.

Why did I suddenly get a message saying that one of my data types could come from more than one table/query even though it only appears once in each of my queries to be joined?

2 out of 3 fields were fine to be specified in the SELECT statement but the third one required me to put it's original table name before it?

My UNION query looks like this:

SELECT [PIN Number], [Student Name], [Course Information].[Course Title]
FROM [Student Numbers Without a Tracker]

UNION ALL SELECT [PIN Number], [Student Name], [Course Information].[Course Title]
FROM [Student Numbers Query];


* Appologies for the table names, I stress that this is NOT my database.

[PIN Number] and [Student Name] are identical in both queries and the same can be said of [Course Title].

I don't mind really as it is now working but I do like to know why for future reference.

Thanks,

Matt.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom