选择相同的客户名称,但具有不同的客户地址

Mas*_*tro 1 t-sql sql-server

尝试选择全部为同一客户的记录,但地址不同的记录.

所以我稍后可以让用户选择Bob Yonkers,然后选择将Bob的所有记录更新为特定地址.所以我想显示所有可用的记录.

数据示例:

CUSTOMER_NAME, CUSTOMER_ADDRESS
Bob Yonkers  , 42 Satellite Cir
Bob Yonkers  , 667 Orbit St
Bob Yonkers  , 42 Satellite Cir
Bob Yonkers  , 667 Orbit St
David Boom   , 5959 Bush Ave
David Boom   , 5959 Bush Ave
David Boom   , 5959 Bush Ave
David Boom   , 5959 Bush Ave
David Boom   , 5959 Bush Ave
Ruby Tuesday , 123 Highway Ln Apt#1
Ruby Tuesday , 123 Highway Ln
David Boom   ,5959 Bush Ave
David Boom   ,5959 Bush Ave
David Boom   ,5959 Bush Ave

所以查询会带回这些结果......

结果示例:

CUSTOMER_NAME, CUSTOMER_ADDRESS
Bob Yonkers  , 42 Satellite Cir
Bob Yonkers  , 667 Orbit St
Ruby Tuesday , 123 Highway Ln Apt#1
Ruby Tuesday , 123 Highway Ln

任何帮助,将不胜感激.

Joe*_*orn 7

SELECT * 
FROM [table] t1
INNER JOIN [table] t2 ON t1.Name=t2.Name AND t1.Address<>t2.Address
Run Code Online (Sandbox Code Playgroud)