|
-
Mar 30th, 2006, 07:49 AM
#1
Thread Starter
Hyperactive Member
SQL in Access Query
I want to select information from two tables that are identical (one as current information and one has archived information)
Table1
T1Key
T1Name
Table2
T2Key
T2Name
Is there anyway of doing a SQL statement to select all information from both tables? Obviously it's not a time for an inner join as they aren't connected.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Mar 30th, 2006, 08:09 AM
#2
Re: SQL in Access Query
select * from table1, table2
-
Mar 30th, 2006, 08:16 AM
#3
Thread Starter
Hyperactive Member
Re: SQL in Access Query
I've tried that but it doesn't select anything and instead brings back the following format
Table1.T1Key Table1.T1Name, Table2.T2Key, Table2.T2Name in one row
rather than
Table1Item
Table1Item
Table1Item
Table2Item
if that makes any sense.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Mar 30th, 2006, 09:21 AM
#4
Re: SQL in Access Query
You need to do a UNION Query
Code:
SELECT T1Key ,T1Name FROM Table1
UNION ALL
SELECT T2Key ,T2Name FROM Table2
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Mar 30th, 2006, 10:29 AM
#5
Thread Starter
Hyperactive Member
Re: SQL in Access Query
Thats great. Thanks.
Is there anyway of grouping them together, so if there are two values of for example T1Name being the same then summing up the keys?
I know there is no reason of summing keys, but it keeps things simple using the same column names I've already mentioned.
ASP, PHP, VB, JavaScript, CSS, HTML, a little C and a little CGI.
Richard Whitehouse.
Join the Footie Predictions League
"Make it idiot proof and someone will make a better idiot."
-
Mar 30th, 2006, 10:53 AM
#6
Re: SQL in Access Query
Use a SELECT DISTINCT instead of just a SELECT to get unique values.
Declan
Don't forget to mark your Thread as resolved.
Take a moment to rate posts that you think are helpful 
-
Mar 30th, 2006, 11:34 AM
#7
Re: SQL in Access Query
If I understood correctly, then this should get what you want:
Code:
SELECT TName, Sum(TKey)
FROM
(SELECT T1Key as TKey, T1Name as TName FROM Table1
UNION ALL
SELECT T2Key as TKey, T2Name as TName FROM Table2)
GROUP BY TName
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|