We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

SQL multiple values JOIN?

simplyfemales
on
Medium Priority
318 Views
Last Modified: 2012-05-11
I have two tables where I want to have the values of column 1, 2 and 3 referenced against column 1 of Table 2 and return a value from column2 of table 2 for each value in table 1.  See below

Table 1

Code1, Code2, Code3

Table 2

Codes, Descriptions

Desired output

Code1, looked up description for code1, Code2, looked up description for code2, Code3, lookedup up description for code3

Any help is greatly appreciated.
Comment
Watch Question

Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:
You are not clear, are Code1, Code2, and Code3 columns of Table1 or are they rows of the table
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:
If rows the simply

select Codes, Description
from Table1
inner join Table2 on Table1.Column1 = Table2.Codes

Author

Commented:
My apologies for being vague.

There are roughly 125 unique codes available in Table 2 (with respective descriptions).  On table 1, I have roughly 500k rows of data where each field in column1 (Code1), column2 (Code2) and column3 (Code3) could be any one of the 125 codes.  I would like to have their respective descriptions matching each code.

Hopefully that helps.
Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
I modified your suggestion of course to fit my tables.  FYI suggestion one I marked (your earlier one) was twice as fast as suggestion 2.  Both worked great though.  Thanks for the quick responses.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.