accp7.0S2优化myschool数据库设计第五章项目

--阶段1
select top 5 * from hos_house as temp where 
HMID not in(select TOP 5 HMID from hos_house order by HMID)order by HMID

--阶段2
select dname,SNAME,HTID,PRICE,TOPIC,CONTENTS,HTIME,COPY from hos_street 
inner join hos_house on hos_house.SID=hos_street.SID
inner join hos_district on hos_district.DID=hos_street.SDID
where UID=(select UID from sys_user where UNAME='张三')

--阶段3
select htname,uname,dname,SNAME from hos_house
inner join sys_user on sys_user.UID=hos_house.UID
inner join hos_type on hos_type.HTID=hos_house.HTID 
inner join hos_street on hos_house.SID=hos_street.SID
inner join hos_district on hos_district.DID=hos_street.SDID
where Sdid in(select SDID from hos_street group by SDID having COUNT(SID)>1)

你可能感兴趣的:(accp7.0S2优化myschool数据库设计第五章项目)