结合SQL Server中不同表和列的两个查询



我有两个SQL Server查询,我需要在C#GridView中显示最终输出结果:

Select *
From PayBack 
Where DATEDIFF(day, GetDate(), (Expirydate)) < 0 
  and DATEPART(yyyy, Expirydate) = '2018' 
  and DATEPART(Month,Expirydate) = '02' 
Select Nomclient, Numero1, Numero2, Numero3, Email1, Email2 
From Client 
Where Nomclient In (Select Client from PayBack)

如何将其合并到一个查询中?

尝试这个 -

Select PB.*,C.Nomclient,C.Numero1,C.Numero2,C.Numero3,C.Email1,C.Email2 
From PayBack as PB
Inner Join Client as C on C.Nomclient = PB.Client
Where DATEDIFF(day,GetDate(),(PB.Expirydate))<0 and
DATEPART(yyyy,PB.Expirydate) = '2018' and DATEPART(Month,PB.Expirydate)='02' 
Select 
    Nomclient,Numero1,Numero2,Numero3,Email1,Email2 
from 
    Client 
where 
    Nomclient in (
        Select Client 
        From PayBack 
        where 
            DATEDIFF(day,GetDate(),(Expirydate))<0 and DATEPART(yyyy,Expirydate) = '2018' 
            and DATEPART(Month,Expirydate)='02'
    )

相关内容

  • 没有找到相关文章

最新更新