Table 1
Part number, Data, Data1, Data2.....
(Part Numer in this table is duplicated multiple times)
Table 2
Part Number, Data 3......
(Part Number in this table is not duplicated)
I would like to create a new table
Table 3
Part Number, Data, Data1, Data2, Data3
I can do this in excel with a vlookup however would like to do this in access
Mike
I'd actually use a modified version of the SQL provided. JOINs work at a different level from linking things via the WHERE clause. While AJ's SQL would work (bar omitting the [Data] field from the output), it would probably struggle (go slowly) when dealing with large numbers of records. - INSERT INTO [Table 3] (
-
[Part Number],
-
[Data],
-
[Data 1],
-
[Data 2],
-
[Data 3])
-
-
SELECT t1.[Part Number],
-
t1.[Data],
-
t1.[Data 1],
-
t1.[Data 2],
-
t2.[Data 3]
-
-
FROM [Table 1] AS t1 INNER JOIN
-
[Table 2] AS t2
-
ON t1.[Part Number]=t2.[Part Number]
11 4422
As long it is as you say, it should simply be this: - INSERT INTO [Table 3] ([Part Number], [Data 1], [Data 2], [Data 3])
-
SELECT [Table 1].[Part Number]
-
, [Table 1].[Data]
-
, [Table 1].[Data 1]
-
, [Table 1].[Data 2]
-
, [Table 2].[Data 3]
-
FROM [Table 1], [Table 2]
-
WHERE [Table 1].[Part Number] = [Table 2].[Part Number]
-AJ
Would this be VBA? I looks like it might work. little lost.
@memiles
This is just a query, you could store it as such, or you could put it in VBA, your choice. Maybe you should state how you wish to use this code, as well as if the data you have is stored in Access tables, and we can help you figure out the best place to put this query.
-AJ
Ok... Table 3 will be a new table based on tables 1 and 2, created from tables one and two. Tables one and two are access tables imported from excel workbooks.
When everything is done I want to send the excel workbook to who ever using db queries.
Does this make sense?
Mike
Mike. If you need I can send data so you can understand.
@memiles
Ok what does this mean, are you going to be the one who imports the data and then run the necessary code to get the Table3 data? Or are you going to be handing this off to someone else after you import this data. I don't think I have a problem understanding the data as you have put it, but you need to explain better the flow of what you intend on doing.
Also, if you have already created Table 1, Table 2, and Table 3, then you should just be able to run the query i provided you as is.
-AJ
I am getting off work, but if no one responds before I do, I will try and respond in the next hour or so. Sorry.
-AJ
This is tens of thousands of lines of data.
It will be going to the FAA so must be absolutly accurate.
Mike
Okay, so you're trying to take two tables that have been imported from an Excel workbook, merge them,and do... what? Port it back to Excel? The SQL aj gave you: - INSERT INTO [Table 3] ([Part Number], [Data 1], [Data 2], [Data 3])
-
SELECT [Table 1].[Part Number]
-
, [Table 1].[Data]
-
, [Table 1].[Data 1]
-
, [Table 1].[Data 2]
-
, [Table 2].[Data 3]
-
FROM [Table 1], [Table 2]
-
WHERE [Table 1].[Part Number] = [Table 2].[Part Number]
-
will work if you paste it into SQL view in Query Designer and "Run" it to create the third table you were asking about. But exactly what do you plan to do with the third table? It may be completely unnecessary to go this route, depending on what you're trying to do.
NeoPa 32,556
Expert Mod 16PB
I'd actually use a modified version of the SQL provided. JOINs work at a different level from linking things via the WHERE clause. While AJ's SQL would work (bar omitting the [Data] field from the output), it would probably struggle (go slowly) when dealing with large numbers of records. - INSERT INTO [Table 3] (
-
[Part Number],
-
[Data],
-
[Data 1],
-
[Data 2],
-
[Data 3])
-
-
SELECT t1.[Part Number],
-
t1.[Data],
-
t1.[Data 1],
-
t1.[Data 2],
-
t2.[Data 3]
-
-
FROM [Table 1] AS t1 INNER JOIN
-
[Table 2] AS t2
-
ON t1.[Part Number]=t2.[Part Number]
After playing around with this at work today I think this will work very slick. Thank you all for your replies.
Mike
Sign in to post your reply or Sign up for a free account.
Similar topics
by: chudson007 |
last post by:
I've got a data set on which I'm trying to perform the same as excel's
vlookup formula using SQL, but do not know how. Can anyone help?
If you picture me having two tables Table_A and Table_B and...
|
by: Fred |
last post by:
I am trying to come up with a way to lookup values in Access as easily as I
can in Excel.
My application is looking up scores. An example lookup table below explains
what I'm after:
TABLE1...
|
by: Fred |
last post by:
I have an application that involves calculating a score based on a number of
defects. Simplified example of the scoring:
No_Defects Score
1-3 A
4-15 ...
|
by: Rebecca |
last post by:
could someone tell me the correct syntax for using vlookup
in visual basic
|
by: Crash91 |
last post by:
I am using this formula in my sheet
=VLOOKUP(A10,table,2)
A10 is a cell that has the function :Left(sheet1!"c10"), it contains the correct value needed for the lookup but its isnt working! Can...
|
by: catlover30 |
last post by:
HI,
I need help with excel VLOOKUP! I am at a new job and really trying to solve this without asking anyone at work, since they seem th expect me to know this. What I am trying to acheive is the...
|
by: ritheshtitu1982 |
last post by:
Hi,
I would like to perform Vlookup in access.
Eg. I have two Tables
Code table
Code --- No
{ ------- 0 ...
|
by: scubasteve |
last post by:
Looking up values from an Access table is simple. Simulating the 'Range Lookup' functionality from Excel's VLookup formula is a bit trickier.
For those that aren't familiar with this, it allows...
|
by: Sinner |
last post by:
Hi,
I have a field name 'USER' in tableMAIN.
How do I replace the user names with corresponding user names. I can
do that in xl using vlookup but now I'm trying to find a way to do
that in...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |