By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,243 Members | 1,654 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,243 IT Pros & Developers. It's quick & easy.

How to match Partial Values

P: 1
I have an excel sheet that I have imported into SQL 2000 and I need to match the values in one to the values in another and have them output the matching codes to a separate table or file.

After re-reading that, it doesn't make a whole lot of sense, so let me give you an example.

In one table I have 3 columns: Name, Description, Number.
In another table I have the same 3 columns. I need to use a query to match the two description columns to each other and when there is a match, put their numbers (numbers from both tables, preferably separated by a comma) into another table or file.

The issue is that I have 1000 values and I want to automate the process.

So lets say I have two tables:
One is called TABLE1 and the other is TABLE2.

In TABLE1 I have
Name Description Number
A This is animal 123
B This is ballon 124
C This is character 125

In TABLE2 I have
Name Description Number
D could be animalwer 321
E could be ballonsdf 187
F could be charcdkeh 222



So in this case, the output file (if I had my wish) would look like:

123, 321
123, 187
125, 222

This would be becase A matched to D and we pulled their numbers, B matched to E and we pulled their numbers and C matched to F.

Can this be done with a relatively simple query?

I'm kinda new to all this Query business so I'd appreciate any help you can give.
Sep 17 '07 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
I have an excel sheet that I have imported into SQL 2000 and I need to match the values in one to the values in another and have them output the matching codes to a separate table or file.

After re-reading that, it doesn't make a whole lot of sense, so let me give you an example.

In one table I have 3 columns: Name, Description, Number.
In another table I have the same 3 columns. I need to use a query to match the two description columns to each other and when there is a match, put their numbers (numbers from both tables, preferably separated by a comma) into another table or file.

The issue is that I have 1000 values and I want to automate the process.

So lets say I have two tables:
One is called TABLE1 and the other is TABLE2.

In TABLE1 I have
Name Description Number
A This is animal 123
B This is ballon 124
C This is character 125

In TABLE2 I have
Name Description Number
D could be animalwer 321
E could be ballonsdf 187
F could be charcdkeh 222



So in this case, the output file (if I had my wish) would look like:

123, 321
123, 187
125, 222

This would be becase A matched to D and we pulled their numbers, B matched to E and we pulled their numbers and C matched to F.

Can this be done with a relatively simple query?

I'm kinda new to all this Query business so I'd appreciate any help you can give.
i would think you would need a cursor on both table since you are trying to see if the string is within the other...
Sep 18 '07 #2

Post your reply

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