Sql 语句之间的查询放置 temptable

Sql query between statement placing temptable

我创建了名为 temp_table 的临时 table 并记录为

       FromDate                ToDate
2011-01-01 00:00:00.000  |  2012-08-16 17:26:44.827
2012-08-16 17:29:06.980  |  2115-01-23 16:29:46.443

我在声明之间放置了

select * 
from payment p 
inner join temp_table t 
    on t.FromDate >= p.CreatedDate 
    or t.toDate <= p.CreatedDate 
where createddate between temp_tbl.FromDate and temp_tbl.ToDate

但它依赖于 1 行语句,我希望这两个语句都被调用。

使用Between操作加入表On条件。试试这个。

select * 
from payment p 
inner join temp_table 
    on  p.CreatedDate between
        temp_tbl.FromDate and temp_tbl.ToDate