【问题标题】:Select from two tables where date are similar but remove the time从日期相似但删除时间的两个表中选择
【发布时间】:2015-09-01 07:31:22
【问题描述】:

我正在尝试从两个表中获取一个表,但我需要在相同日期之前同步记录而不需要时间

select  *
from Transactions , SellerIPLogins
where Transactions.SellerId =SellerIPLogins.SellerId
  and Transactions.SellerId=3141 and Transactions.Payment>1
  and **Transactions.Date=SellerIPLogins.Date**
order by Transactions.Date desc

【问题讨论】:

    标签: sql sql-server


    【解决方案1】:

    使用Convert方法将日期时间转换为日期:

    select  *
        from Transactions , SellerIPLogins
        where Transactions.SellerId =SellerIPLogins.SellerId
          and Transactions.SellerId=3141 and Transactions.Payment>1
          and Convert(date,Transactions.Date)=Convert(date,SellerIPLogins.Date)
        order by Transactions.Date desc
    

    【讨论】:

    • 这不是一个很好的答案。请发布描述,而不仅仅是代码。
    • @JamieRees,好的,但实时回答的最佳方法是发布一个简短的答案,然后稍后对其进行编辑以获得完整的答案。
    猜你喜欢
    • 2016-01-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 2014-07-01
    • 1970-01-01
    • 2015-07-11
    相关资源
    最近更新 更多