加入两个表并仅在与另一个表中的数据匹配时获取数据

时间:2022-03-11 11:59:36

I have two tables:

我有两张桌子:

 Tbl1 
 AuthID         ClientID          ClientNote
 1              12                First Appointment
 2              13                First Appointment


 tbl2
 EligID         ClientID          TypeA          DateA
 1              12                1              12/30/2015
 2              12                2              5/30/2016
 3              13                1              2/13/2016
 4              13                2              7/30/2016

I want to only to select clients from tbl1 which have TypeA = 1 and DateA is between 01/01/2016 and 06/30/2016 in tbl2.

我想只选择来自tbl1的客户,其中TypeA = 1且DateA在2016年1月1日至2016年6月30日期间在tbl2中。

1 个解决方案

#1


3  

SELECT tbl1.*
  FROM tbl1
  INNER JOIN tbl2 ON tbl1.ClientID = tbl2.ClientID
WHERE tbl2.TypeA = 1 AND tbl2.DateA BETWEEN '2016-01-01' AND '2016-06-30'

Should get done what you are looking for.

应该完成你想要的。

#1


3  

SELECT tbl1.*
  FROM tbl1
  INNER JOIN tbl2 ON tbl1.ClientID = tbl2.ClientID
WHERE tbl2.TypeA = 1 AND tbl2.DateA BETWEEN '2016-01-01' AND '2016-06-30'

Should get done what you are looking for.

应该完成你想要的。