Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In database terms, you want to LEFT JOIN all the rows in your Excel
range (table on the left) to those in the your external database (table on the right) or a row of nulls if there is no match. The join would look something like this: SELECT T1.Col1, T1.Col2, T1.Col3, T2.LookupCol As NewCol FROM MyExcelData T1 LEFT JOIN MyExternalData T2 ON T1.Col1=T2.Col1 AND T1.Col2=T2.Col2 AND T1.Col3=T2.Col3 I've never known a RDBMS allow you to JOIN tables from different data sources on the fly i.e. without previously linking servers (SQL Server) or using linked tables (MS Access). You need both tables in the same 'place'. Also, in database terms, you are talking about appending a new column to an existing table, which is not something normally done on the fly with a query! So it makes me wonder: is this a one off or something you will be doing regularly in an Excel application? If it's a one off, you are probably best off importing or linking the Excel data within the RDBMS, create a new table locally using a LEFT JOIN, then updating the original Excel source. If it was a regular thing, it would be difficult to do all this in code from Excel if you wanted to repeat regularly. Post back with some more details e.g. the external database (MS Access, SQL Server, another Excel workbook etc), what your data looks like (Excel and external), how often you plan to do this, whether to run from code, etc. -- "Stephen Goldfinger" wrote in message ... Howdy. I have a worksheet where each row has several columns with values. I want to take these column values and look up a value from an external database. I also don't want to create a query for each row (since there are many thousands of rows). I know how to get a query to return a value for a single row, but is there a way to get a query to return a value for each row and place the result in a column at the end of the row whose values are being matched. Thanks in advance for your help. Stephen |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Querying Large Database | Excel Discussion (Misc queries) | |||
Summing values in a database against certain criteria | Excel Worksheet Functions | |||
SUMIF positive values only from database | Excel Worksheet Functions | |||
How to aggregate values in a database | Excel Worksheet Functions | |||
Querying Access Database | Excel Worksheet Functions |