0

我有 2 个表我想从 Requirement 表中选择过去 15 天内具有 RService 和 RSubService = 'No Requirement' 的记录,并且表 EnquiryMaster 表中对应的 MobileIT 和 PhoneIT 为空或未输入

  EnquiryMaster       
   [EnquiryId]
  ,[Company]
  ,[HeadOfficeAddress]
  ,[ContactPersonIT]
  ,[EmailIT]
  ,[MobileIT]
  ,[PhoneIT]
  ,[date]



   Requirement-
   [RequirementID]
  ,[EnquiryID]
  ,[Company]
  ,[RService]
  ,[RSubService]
  ,[RDetails]
  ,[RDate]
4

3 回答 3

2
select *
  from dbo.EnquiryMaster as em
  left join dbo.Requirement as r
    on em.EnquiryId = r.EnquiryID
 where r.MobileIT is null 
   and r.PhoneIT is null
   and em.RService ='No Requirement'
   and em.RSubService ='No Requirement'
   and em.date >= dateadd(day, -15, getdate())
于 2013-06-14T05:44:03.193 回答
1
select * from EnquiryMaster em
inner join Requirement r on r.EnquiryId = em.EnquiryID
where r.MobileIT is null and r.PhoneIT is null and em.RSubService ='No Requirement'
于 2013-06-14T05:41:40.533 回答
1
    select * from EnquiryMaster e, Requirement r 
    where e.EnquiryId = r.EnquiryID 
    and RService = 'No Requirement'
    and RSubService = 'No Requirement'
于 2013-06-14T05:43:44.780 回答