View Full Version : Combining Tables... HELP!
Jess77 02-22-2007, 04:25 AM :confused: I need help desperately. I have two tables I am trying to comine in a query. Seems easy enough right? Yet the simple task has become impossible. I have two tables with the same feild for data, both containing 8 coulmns. Ex:
Table A-January
Columns
A B C
Data: 1,2,3
Table B-February
Columns
A B C
Data: 4,5,6
I'm trying to create a query that will contain the data 1,2,3,4,5,6 but am getting 11111111111,222222222,33333333333,4444444444,55555 55555,6666666, or getting 1,3,5. I've tried refining the data in many ways, even tried just created a table. Hand keying it in seems rediculous due to the end numbers being over 10,000. Any advice??? Please??? :(
Why do you have two tables with the same fields?
Jess77 02-22-2007, 04:31 AM I have two tables not with the same exact data, but the same data entry perameters. I created a log my month and now want to combing such to make a log for the year without having to reenter everything.
namliam 02-22-2007, 04:33 AM Without the tables having a common key field, it is going to be pretty hard...
Have you tried adding an autonumber field? and linking the 2 tables on that?
Jess77 02-22-2007, 04:36 AM Yes.. but it's giving me crazy amounts of doubles ok.. say one table has 2000 files the other has 700.. it gives me an end product of 150000 instead of 2700.
Dennisk 02-22-2007, 04:39 AM use a union query to combine to tables.
if the number of columns are the same in each table then
Select * from tblmyTable
UNION
Select * from tblmyTabl1
otherwise list each field. Also the column names from the first table will be used .
namliam 02-22-2007, 04:41 AM Yes offcourse that is what we call a cartegian (spelling may be wrong) product.
It joins each record of table A with each record of table B. 2000 * 700 = 1.400.000 records....
Considering you rounded the numbers that seems to be correct.
Have you tried a Union? Does that do what you are looking for???
Go into the SQL design and make a query like so:
Select * from TableA
union all
Select * from TableB
But why log different months in different tables? Why not do it simply in 1 table? 2700 doesnt seem unbarable for 1 table to contain, even 24000 (projected to a full year) is fine!
Jess77 02-22-2007, 04:46 AM I know it sound rediculous.. But I'm just following directions. For the chart and figures I'm working with, It does make the most sense...
Jess77 02-22-2007, 04:48 AM It's giving me a syntax error... irritating.
neileg 02-22-2007, 04:55 AM Yes offcourse that is what we call a cartegian (spelling may be wrong) product. It's cartesian.
I know it sound rediculous.. But I'm just following directions. For the chart and figures I'm working with, It does make the most sense...No it doesn't. Bad design never makes sense. However, if you are stuck with the design you've got, you've go to work with it.
It's giving me a syntax error... irritating.
If you post the SQL of your union query perhaps we can sort it for you.
namliam 02-22-2007, 05:19 AM It's cartesian.
Hmz... See spelling is not my best class :)
neileg 02-22-2007, 06:30 AM Hmz... See spelling is not my best class :)
Well I can't speak Dutch, never mind get the spelling right!
namliam 02-22-2007, 06:45 AM LOL, but cartesian is a business word and should know that one...
Koud he?, It is cold isn't it?
Lekker, Tasty
Lekker ding, "Tasty" person of the opposite sex ;)
Vriendelijke groeten uit Amsterdam
Best regards from Amsterdam, so there you know a few words Dutch and you cannot say that anymore ;)
So you're creating a new table every month, in which case you'll have to write a new Union Query every month, sounds like madness to me
neileg 02-23-2007, 03:00 AM LOL, but cartesian is a business word and should know that one...
Koud he?, It is cold isn't it?
Lekker, Tasty
Lekker ding, "Tasty" person of the opposite sex ;)
Vriendelijke groeten uit Amsterdam
Best regards from Amsterdam, so there you know a few words Dutch and you cannot say that anymore ;)
You've just reduced my vast area of ignorance by a tiny amount!
Interestingly, where I come from in the UK (near Newcastle) we would say Cowld, eh? which is pretty close to Koud he?
namliam 02-23-2007, 03:36 AM Languages, dialects and more in particular slang has more in comon than one thinks
|
|