473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

vlookup vs access

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
Nov 24 '09 #1

✓ answered by NeoPa

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.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Table 3] (
  2.        [Part Number],
  3.        [Data],
  4.        [Data 1],
  5.        [Data 2],
  6.        [Data 3])
  7.  
  8. SELECT t1.[Part Number],
  9.        t1.[Data],
  10.        t1.[Data 1],
  11.        t1.[Data 2],
  12.        t2.[Data 3]
  13.  
  14. FROM   [Table 1] AS t1 INNER JOIN
  15.        [Table 2] AS t2
  16.   ON   t1.[Part Number]=t2.[Part Number]

11 4422
ajalwaysus
266 Expert 100+
As long it is as you say, it should simply be this:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Table 3] ([Part Number], [Data 1], [Data 2], [Data 3])
  2. SELECT [Table 1].[Part Number]
  3.             , [Table 1].[Data]
  4.             , [Table 1].[Data 1]
  5.             , [Table 1].[Data 2]
  6.             , [Table 2].[Data 3]
  7. FROM [Table 1], [Table 2]
  8. WHERE [Table 1].[Part Number] = [Table 2].[Part Number]
-AJ
Nov 24 '09 #2
Would this be VBA? I looks like it might work. little lost.
Nov 24 '09 #3
ajalwaysus
266 Expert 100+
@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
Nov 24 '09 #4
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.
Nov 24 '09 #5
ajalwaysus
266 Expert 100+
@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
Nov 24 '09 #6
ajalwaysus
266 Expert 100+
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
Nov 24 '09 #7
This is tens of thousands of lines of data.
Nov 24 '09 #8
It will be going to the FAA so must be absolutly accurate.

Mike
Nov 24 '09 #9
topher23
234 Expert 100+
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:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Table 3] ([Part Number], [Data 1], [Data 2], [Data 3]) 
  2. SELECT [Table 1].[Part Number] 
  3.             , [Table 1].[Data] 
  4.             , [Table 1].[Data 1] 
  5.             , [Table 1].[Data 2] 
  6.             , [Table 2].[Data 3] 
  7. FROM [Table 1], [Table 2] 
  8. WHERE [Table 1].[Part Number] = [Table 2].[Part Number] 
  9.  
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.
Nov 25 '09 #10
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.
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [Table 3] (
  2.        [Part Number],
  3.        [Data],
  4.        [Data 1],
  5.        [Data 2],
  6.        [Data 3])
  7.  
  8. SELECT t1.[Part Number],
  9.        t1.[Data],
  10.        t1.[Data 1],
  11.        t1.[Data 2],
  12.        t2.[Data 3]
  13.  
  14. FROM   [Table 1] AS t1 INNER JOIN
  15.        [Table 2] AS t2
  16.   ON   t1.[Part Number]=t2.[Part Number]
Nov 30 '09 #11
After playing around with this at work today I think this will work very slick. Thank you all for your replies.

Mike
Dec 1 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
3
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...
3
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 ...
2
by: Rebecca | last post by:
could someone tell me the correct syntax for using vlookup in visual basic
1
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...
5
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...
4
by: ritheshtitu1982 | last post by:
Hi, I would like to perform Vlookup in access. Eg. I have two Tables Code table Code --- No { ------- 0 ...
1
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...
9
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...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.