combining tables with a twist

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,892
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
  8. 2003 or older
Platform
  1. Windows
tableA has a unique key (key1), this can occur many times in tableB (key1), tableB (key2) occurs the same number of times in tableC

It is a sort of lookup of codes which finally resolves to a text string, I want to be able to link all this together to get the text value from tableC appended to all the data in tableA, effectively all the keywords at the end of the data, these can be from 0 to N.

It would have been easier if the original designer had just put the ref codes in table A instead of the method used. I have been looking at UNION and CROSSTAB with no success
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Hi Jim, if i understand correctly you have Table A linked one-to-many to Table B, and Table B linked one-to-many to Table C (or possibly one-to-one). And you want a field in Table C aligned with data in Table A. OK so far?

In the query builder, add all 3 tables. If the links don't appear between the tables, drag and drop to connect them. Now double-click the asterisk in Table A to get all fields, and the field you want to line up in Table C. View the query and you should have what you want. Use the query for reports, but leave the tables s they are. Don't try to put the Table C field in Table A -- you'll have redundant data entry if you do (which is why the designer set it up that way)

Does that help?

Denis
 
Upvote 0
when viewing the query I get multiple lines in the new table depending on the number of keywords that exist in tableB, tableC.

Ideally I want one line, with the multiples appended to the end of the record
 
Upvote 0
the format I want is as follows

record 1, k1,k2,k3...kn

currently I get

record1, k1
record1, k2
record1, k3
.
.
.
record1, kn

I have tried using DISTINCT but with no success
 
Upvote 0
Denis

Thanks for input, I have decided to run with the multiple row thing and then export as EXCEL and write a < 20 line macro to shift the data to another sheet a new line everytime the pimary key changes.

Thankfully it is a one off, extracting data from Visual Fox pro, library management system into SQL server based something else.

Boy do these quite librarians know how to write the most crap, obtuse code in their own little vertical domain, grrrrrr

Lets close the call on that note
 
Upvote 0

Forum statistics

Threads
1,221,848
Messages
6,162,419
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top