数据库 夺标查询2
来源:互联网 发布:淘宝上的电脑是真货吗 编辑:程序博客网 时间:2024/05/17 15:56
--等值连接
--查询所有产品及它们的供应商名称。
select ProductName,CompanyName from
dbo.Products inner join dbo.Suppliers
on dbo.Products.SupplierID=Suppliers.SupplierID
--非等值连接
--查询所有价格高于20的商品名及供应商
select ProductName,CompanyName,UnitPrice
from Products inner join dbo.Suppliers
on Products.SupplierID = Suppliers.SupplierID
where UnitPrice > 20
order by UnitPrice
select ProductName,CompanyName,UnitPrice
from Products inner join dbo.Suppliers
on Products.SupplierID = Suppliers.SupplierID
and UnitPrice > 20
order by UnitPrice
--=====================================
select * from Products
--复制表
select * into Products_new from Products
select ProductID,ProductName
into Products_new2
from Products
where UnitPrice > 20
--联合查询
select ProductID,ProductName from Products
union all
select ProductID,ProductName from Products_new
-- SELECT select_list
-- [ INTO new_table ]
-- FROM table_source
-- [ WHERE search_condition ]
-- [ GROUP BY group_by_expression ]
-- [ HAVING search_condition ]
-- [ ORDER BY order_expression [ ASC | DESC ] ]
-------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
if exists(select * from sysobjects
where name = 'a' and type = 'U')
drop table a
go
create table a
(
id int,
name varchar(6)
)
insert a values(1,'a')
insert a values(2,'b')
insert a values(3,'c')
insert a values(4,'d')
if exists(select * from sysobjects
where name = 'b' and type = 'U')
drop table b
go
select * into b from a
select * from a
select * from b
--1.
select * from a left join b on a.id=b.id where a.id=1
--2.
select * from a left join b on a.id=b.id and a.id=1
--3.
select * from a left join b on a.id=b.id and b.id=1
--4.
select * from a left join b on a.id=1
- 数据库 夺标查询2
- oracle数据库的夺标查询
- 夺标
- 一步一步学MySQL----14 夺标数据记录查询之外连接
- 夺标要
- 数据库查询汇总(2)
- 数据库查询2
- 数据库的查询2
- 【数据库】2查询
- oracle 数据库查询-关联查询-2
- (2)php数据库查询-查询
- 数据库(2) SQL查询--简单查询
- 数据库知识补充(2)---数据库查询优化
- 13.数据库查询语言2
- TreeView 数据库查询节点2
- 2#plsql 查询数据库乱码
- [2]数据库附加子句查询
- 数据库查询
- JPivot的MVC结构和设计模式
- 触发器在插入时更新此条新记录 错误it is already used by statement which invoked this stored functiontrigger的解决方法
- ASP.net 的URL路由选择(System.Web.Routing.dll)
- 传智博客课堂学习笔记3.27
- debugging information corrupt; recompile module 解决办法
- 数据库 夺标查询2
- 看过的书
- java集合类
- 设计模式--桥接模式(Bridge)
- c# 设为首页和加入收藏代码收藏
- SharePoint Designer Check In and Check Out Error – Cannot perform this operation.The file is no longer check out or has been del
- 九句电影台词搞定面试官
- 寻友同学有限元
- 养老金 nest egg