select a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,b.LastTime
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0select top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc这是两个Sql语句,要把这俩读出的内容一起显示出来,并且不能重复,这个怎么俩个写成一个啊
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0select top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc这是两个Sql语句,要把这俩读出的内容一起显示出来,并且不能重复,这个怎么俩个写成一个啊
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0
union all------------------
select top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc
select a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,b.LastTime
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0 union allselect top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0
union
select top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc
union all 包含重复数据的 应该用union
select a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,b.LastTime
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0 unionselect top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0 order by LastTime desc
(select a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,b.LastTime
from
tb_Lawyer_User a right join tb_OnLine_User b on a.UserID=b.UserID
left join tb_Pro c on a.ProID=c.id join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where b.UserType=1 and a.Hidden=0 unionselect top 10 a.ID,a.FullName,a.SmallNamePath,c.name as ProName,d.Name as CityName,e.Domain,a.LastTime
from tb_Lawyer_User a left join tb_Pro c on a.ProID=c.id
left join tb_City d on a.CityID=d.id
left join tb_Domain e on (a.UserID=e.UserID and e.UserType=1)
where a.Hidden=0)t order by LastTime desc