sql查询

--使用Northwind 数据库
--比较条件查询
-- 大于 >
select * from Products where unitprice>25
go
--等于 =
select * from Products where unitprice=25
go
--小于 <
select * from Products where unitprice<25
go
--不等于 <>
select * from Products where unitprice<>25
go
--范围查询条件
--BETWEEN..AND.. 
select * from Products where unitprice between 25 and 40
go
--NOT BETWEEN..AND..
select * from Products where unitprice not between 25 and 40
go
--列表查询条件
--IN(目标值1,目标值n)
select * from Products where supplierID in(1,2,3,4,5,6)
go
--NOT IN(目标值1,目标值n)
select * from Products where supplierID not in(1,2,3,4,5,6)
go
--模糊查询
--"%"通配符
select * from Products where productname like '%Pa%'
go
select * from Products where productname like 'Pa%'
go
--"_"通配符
select * from Products where productname like 'Pa_l%'
go
--"[]"通配符
select * from Products where productname like '%Pa[a-s]%'
go
--"[^]"通配符
select * from Products where productname like '%Pa[^a-s]%'
go
posted @ 2011-03-28 22:17  天璇翼  阅读(331)  评论(0编辑  收藏  举报