简体   繁体   English

将一列中的 TEXT 或 Alphanumber 值与 SQL Server 中另一列的值匹配

[英]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.我必须查看 A 列中的值与不同表的 B 列中的值是否匹配。 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.因此,通过 30,000 条记录,我必须显示每场比赛的客户编号以及比赛本身。

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.因此,结果将是两件事,一是将 Customer # 和 TO BE 插入到名为 Column C. 的单独列中,另外还有一个显示 Customer # 和 TO BE 文本的列表。

Please help!!!请帮忙!!!

You need JOIN (i think) :你需要JOIN (我认为):

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL Server:通过匹配不同列中的值,用同一列中的值替换Null值 - SQL Server : replace Null values with values from the same column by matching values in a different column 在同一表中查找从一列到另一列的匹配值 SQL 服务器 - Find matching values from one column to another column in same table SQL Server 选择多个值作为一列,而不是每个值的列,SQL Server - Select many values as one column, not a column for each value, SQL Server 如何基于SQL Server中当前表列的值使用与其他表不同的列值 - How to use different column values from other table based on value on current table column in SQL server 在SQL中将一列中的一个值与另一列中的多个值匹配 - Matching one value in one column with more than one values in other column in SQL SQL列重复项匹配不同的值 - SQL Column duplicates matching different values SQL根据另一列中的值从一列中选择值 - SQL select value from one column based on values in another column 如何根据 SQL Server 中的另一列将一列值转换为两个不同的列值? - How to convert one column values to two different column values based on other column in SQL Server? 用于匹配一列中的多个值的SQL查询 - Sql query for matching multiple values in one column 基于列2 SQL Server的列1的不同值 - Different values of column 1 based on column 2 SQL Server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM