【发布时间】:2017-01-19 06:27:39
【问题描述】:
我真的不知道怎么问这个问题。
我将使用我需要加入的两个表来说明它。
TABLE_1
Name Date
John 01-01-2016
May 04-08-2015
Rose 10-25-2016
Mary 12-15-2015
Ruby 07-07-2017
表_2
Signatory DateFrom DateTo
President 1 01-01-2015 12-31-2015
President 2 01-01-2016 12-31-2016
结果:
Name Date Signatory
John 01-01-2016 President 2
May 04-08-2015 President 1
Rose 10-25-2016 President 2
Mary 12-15-2015 President 1
Ruby 07-07-2017 NULL
我只需要检查 Table_1 的 Date 是否在 Table_2 的 DateFrom 和 DateTo 内获取 Signatory 字段。
我该怎么做?
非常感谢! ^_^
【问题讨论】:
-
基本上你需要一个包含每个日期的表格。在这里查看答案。 stackoverflow.com/questions/11391085/…
-
从谷歌搜索每个日期从开始到结束 postgresql google.com.au/…
标签: sql postgresql