简体   繁体   中英

Matching a TEXT or Alphanumber value from one column to the values of a different column in SQL Server

I have to see if there is a match of values from Column A with the Column B of a different table. Below is an example I have listed,

CUSTOMER # Column A Table A       CUSTOMER #  Column A  Table B
11111      TO BE                  12345       ,XXXX,TO BE,/TO BE/

I could have it right below as well if it makes it easier, (Same Table but different column,

CUSTOMER # Column A Table A       CUSTOMER # Column B  Table A
11111      TO BE                  11111      ,XXXX,TO BE,/TO BE/

So going through 30,000 records, I have to show the customer # for every match and the match itself.

So, the result would be two things, one insert the Customer # and TO BE to a separate Column called Column C. and also a listing that shows the Customer # and the TO BE Text.

Please help!!!

You need JOIN (i think) :

SELECT a.customer, a.columnA as [column a from a], b.customer, b.columnA as [column a from b]
FROM tableA a INNER JOIN
     tableB b
     ON b.customer = a.customer;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM