As a programmer, it's really hard to have any insight, that is, to some people who have just learned to program, hoping to give them some help!
SQL Server is not too difficult to get started as a database for beginners to learn! In other words, building a library, building tables, building constraints, database tables to increase the deletion of the search!
But today is mainly about the query, the most important is the most difficult part!
First of all, look at this piece of code:
Select Dname as counties, SNAME as streets, Hos_type. Htid as type, price as, CONTENTS as description, COPY as memo from Hos_house left outer
Join Sys_user on Sys_user. Uid=hos_house. Uid
Join Hos_street on Hos_street. Sid=hos_house. Sid
Join Hos_district on Hos_district. Did=hos_street. Sdid
Join Hos_type on Hos_type. Htid=hos_house. Htid
and Hos_house. UID in
(
Select UID from Sys_user where Uname= ' Zhang San '
)
This code uses the left Outer connection query, inquires the Zhang San all housing information!
Select Top 5 * from Hos_house where
(
Hmid not in
(
Select Top 5 hmid from Hos_house ORDER by Hmid
)
)
It's a simple paging!
Select Htname as type, UNAME as name, dname as County, SNAME as street from hos_house left outer
Join Sys_user on Sys_user. Uid=hos_house. Uid
Join Hos_street on Hos_street. Sid=hos_house. Sid
Join Hos_district on Hos_district. Did=hos_street. Sdid
Join Hos_type on Hos_type. Htid=hos_house. Htid
where Hos_district. did in
(
Select Sdid from Hos_street where Sdid in
(
Select SID from Hos_house Group by SID have (COUNT (*) >=1)
) Group by Sdid have (COUNT (*) >=2)
) Order BY Sdid
This code is more difficult, query the street, the community at least a community, a cell at least two rental information, this code to understand not difficult, it is rare to write whether you want to be thoughtful!
Some personal understanding of SQL statement queries in SQL Server