如何 select 只记录在 table b

How to select records only in table b

我有两个 table。 Table A 和 Table B。它们都有两列(姓名和薪水)。两个table都有重名记录但是薪水不同。我如何编写查询 select Table A 的姓名和薪水,其中 table A 的姓名在 table B 的姓名列中。

MYSQL 或 MSSQL

Table A 
Name        Salary
john smith  100
john smith  100
sally smith 100
Dan smith   100


Table B 
Name        Salary
john smith  100
john smith  100
sally smith 100

result  
Name    Salary
john smith  100
john smith  100
sally smith 100

试试这个:

SELECT Name, Salary
  FROM Table_A
 WHERE Name IN (SELECT DISTINCT Name
                  FROM Table_B)      ;