我有两张桌子:
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
我只想从tbl1
中选择TypeA = 1
和DateA is between 01/01/2016 and 06/30/2016
tbl2
的客户。
答案 0 :(得分: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'
应该完成你想要的工作。