sqlserver2012学习笔记
select ProductID, Name as ProductName, --using an alias
'The list price for ' + ProductNumber + ' is
′+convert(varchar,ListPrice)+′.′,−−usingtheconcatenationtojoincharacterend−to−end.′Thelistpricefor′+ProductNumber+′is ' + convert(varchar,ListPrice) +'.' as [Description] --using brackets to let SQL server conside the strin as a column name
from Production.Product
sql自学难吗在where语句中⽤>,=,<;等字符
eg:
select * from [Sales].[SalesOrderHeader]
where SalesPersonID=275
select * from [Sales].[SalesOrderHeader]
where SalesOrderNumber='so43670'  //string类型加单引号
where语句中使⽤or或and
eg:
select SalesOrderID,OrderDate,SalesPersonID,TotalDue as TotalSales
from [Sales].[SalesOrderHeader]
where SalesPersonID=275 and TotalDue>5000 and Orderdate between '2005-08-01' and '1/1/2006'
like中使⽤%号  //%表⽰可以有,可以没有
select * from [Production].[Product]
where name like'Mountain'
select * from [Production].[Product]
where name like'%Mountain%' --Wildcard % matches any zero or more characters
_下划线表⽰前⾯有⼀个不知道的字符
select * from [Production].[Product]
where name like'_ountain%'
Where语句中使⽤in或not in
select * from [Production].[Product]
where color in ('red','white','black')
select * from [Production].[Product]
where class not in ('H') -- same as using: <> 'H'//没有H的
is null 与is not null
--Topic 10
select * from [Production].[Product]
where size is null
select * from [Production].[Product]
where size is not null
or与and的理解
Processing math: 100%

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。