select NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_Volunteer as b on a.AllowedOrg like'%,'+convert(varchar(50),b.OrgID)+',%' and  b.volunteerID='1'select NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_TeamMember as b on a.TeamID=b.TeamID where b.VolunteerID='1'第一条语句结果
1 xcv          2010-05-04 15:24:24.000
2 afdsfasd 2010-05-03 15:26:47.000
3 adsf 2010-05-03 15:35:27.000
第二条语句结果
9 fdsafadsf 2010-05-08 16:04:58.000请问我要用一条语句完成这个结果,也就是我想用一条语句达到下面这个结果:
1 xcv          2010-05-04 15:24:24.000
2 afdsfasd 2010-05-03 15:26:47.000
3 adsf          2010-05-03 15:35:27.000
9 fdsafadsf 2010-05-08 16:04:58.000
语句该怎么写?

解决方案 »

  1.   

    最简单的就是select NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_Volunteer as b on a.AllowedOrg like'%,'+convert(varchar(50),b.OrgID)+',%' and b.volunteerID='1'
    union all
    select NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_TeamMember as b on a.TeamID=b.TeamID where b.VolunteerID='1'
      

  2.   

    'try:'
    select NotifyID,NotifyTitle,NotifyTime
    from T_EV_Notify as a inner join T_EV_Volunteer as b
    on a.AllowedOrg like'%,'+convert(varchar(50),b.OrgID)+',%'
    inner join T_EV_TeamMember as c
    on a.TeamID=c.TeamID
    where c.VolunteerID='1' or b.volunteerID='1'
      

  3.   


    --直接union allselect NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_Volunteer as b on a.AllowedOrg like'%,'+convert(varchar(50),b.OrgID)+',%' and b.volunteerID='1'
    union all
    select NotifyID,NotifyTitle,NotifyTime from T_EV_Notify as a inner join T_EV_TeamMember as b on a.TeamID=b.TeamID where b.VolunteerID='1'