从日期相似的两个表中选择,但删除时间

时间:2015-09-01 07:31:23

标签: sql sql-server

我正在尝试从两个表中获取一个表,但我需要在没有时间的情况下将记录同步到同一时间

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

1 个答案:

答案 0 :(得分: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