SQL JOIN and UNION versus VBA

exaccess

Registered User.
Local time
Today, 20:55
Joined
Apr 21, 2013
Messages
287
Hello Experts,
I have a table and a query. The first 4 fields of the table correspond to that of the query. The query does not have any other fields, but the table has 26 more fields. Is it possible to use SQL OUTER JOIN or UNION or whatever to append the data of the query to the table or do I have to go with recordsets of VBA?
 
Ass long as none of those 26 fields are required in the table all you need is an APPEND query. From your description, UNION and OUTER joins don't even enter the conversation.
 
Ass long as none of those 26 fields are required in the table all you need is an APPEND query. From your description, UNION and OUTER joins don't even enter the conversation.
OK Perfect. But what if I need those fields. That is the result is lets say will be a table where the first 1200 records have all 30 fields populated and the rest 500 records have 4 fields populated and have nulls in the remaining 26 fields. Which way should I follow in that case.
 
But what if I need those fields.

Now, you've lost me. Intially you said you had a query that produced 4 fields, all of which matched fields in a table. The table had an additional 26 fields that the query did not.

Now, I have no idea what you mean by "those fields".
 
Now, you've lost me. Intially you said you had a query that produced 4 fields, all of which matched fields in a table. The table had an additional 26 fields that the query did not.

Now, I have no idea what you mean by "those fields".

OK. Sorry if I am not clear enough.
Table 1 Fields: F1, F2, F3 , F4, F5, F6, F7, F8, F9, F10
Query 1 Fields: G1, G2, G3, G4

F1 corresponds to G1 , F2 corresponds to G2 , F3 corresponds to G3 , F4 corresponds to G4. The data in these corresponding fields can be compared. Only their names are different. Now what I want to do is to append Query1 to Table1 giving Table2. When that happens the Table2 will have fields say H1, H2, H3, H4 populated in all records but the other fields H5 to H10 will contain nullls. This is what I meant by "those fields".
 
Now what I want to do is to append Query1 to Table1 giving Table2.

Okay, stop using database jargon, you are only confusing me further. APPEND is a very specific action. It adds data to an existing table, it does not create a new one. Appending query1 data to table1, does not create table2, it increases the number of records in table1.

So start over, and use data to demonstrate what you want to occur. Use real table and field names, and sample values in those fields. Show me what you are starting with and what you expect to finish with. Additionally, tell me why you think you need a whole new table; that's not how databases generaly work. No more generalities, explain the whole system and what you hope to accomplish without using any more database terms.
 
OK. I have solved the problem. I have created a replicate of Table1 say TableFin. Then I copied Table1 into it with INSERT INTO. I formed Query1 as a temporary table say TEMPO. Finally I appended TEMPO to TableFin by copying the first four fields of TEMPO to the first four of TableFin. The rest 26 fields of TableFin contain nulls.
 

Users who are viewing this thread

Back
Top Bottom