sql查询:联合查询
发布时间:2011年04月26日点击数:
次佚名
-
-
-
- select p.* from Products p inner join [Order Details] o on p.ProductID=o.ProductID
- go
- select p.*,c.* from Products p inner join Categories c on c.CategoryID=p.CategoryID
- go
-
-
- select p.*,c.* from Categories c left outer join Products p on p.CategoryID=c.CategoryID order by p.ProductID
-
- select p.*,c.* from Categories c right outer join Products p on p.CategoryID=c.CategoryID order by p.ProductID
-
- select p.*,c.* from Categories c full outer join Products p on p.CategoryID=c.CategoryID order by p.ProductID
-
-
-
- select * from Products where unitprice>(select avg(unitprice) from Products)
-
- select * from Products where categoryID in (select categoryID from categories)
-
-
- select * from Products where unitprice<some(select avg(unitprice) from Products)
-
-
-
-
- select * from Products where unitprice<>All(select avg(unitprice) from Products)
-
-
- select * from Products where exists (select * from categories where categories.categoryID=Products.categoryID and categories.categoryID=2)