SQL server(二)运算符

--算数运算符

-- = + - * / %取余

declare @a int,@b int;
select @a=10,@b=3;
print(@a%@b)--余数为1

--比较运算符
-- > < = >= <=  <>不等于,!=  !>  !<  其中 !=   !<  !>  不是ansi标准运算符

--逻辑运算符
-- all   一个比较集中全部是true,则为true
-- and   如果两个布尔表达式均为true,则为true
-- any     如果一个比较集中任何一个为true,则为true
-- between 如果操作数是在某一个区间范围,则为true
-- exists 如果子查询包含任何行,则为true
-- in 如果操作数与一个表达式列表中的某个相等的话,则为true
-- like 如果操作数匹配某个模式的话,则为true
-- not  对任何其他布尔运算符取反
-- or    如果任何一个布尔表达式为true,则为true
-- some 如果一个比较集中某些为true,则为true

select * from stduser where gender='woman' and age>300;
--当 not and or 同时出现在一个表达式中时,优先级,not and or

--通配符
-- % 包括零个或更多字符的任意集合, 'loving%' 可以表示: 'loving' 'loving123'  'loving?'
-- _ 任何单个字符, 
-- [] 指定范围[a~f]或集合[abcdef] 中任意单个字符,[0~9]123 表示0~9之间任意取一个,以123结尾的字符串
-- [^] 不属于指定范围或者集合的任何字符 ,[^0~5]123 表示不以 0~5 开头的任意一个字符开头,却以123结尾的字符串。
原文地址:https://www.cnblogs.com/yuanshuang-club/p/13639531.html