常用SQL(一)

--查看全表
select * from emp;

--IN 和 NOT IN
select * from emp where sal in (800,1600);
--等价于
select * from emp where sal=800 or sal=1600;

-- BETWEEN…AND… 范围(在上限和下限之间)
select * from emp where sal between 800 and 1600;
--等价于
select * from emp where sal>=800 and sal<=1600;

-- IS NULL 和 IS NOT NULL 找出NULL值或非NULL 值
-- 遇到null,则一定要用is
select * from emp where comm = null;

--LIKE 模式匹配(或模糊查询) 在搜索字符串中使用通配符 “%”和”_” ,“%”号代表0个或多个字符,
--而”_”则表示单个字符.如果搜索字符串中需要查询实际的”%”和”_”,那么就需要在搜索字符串中使
--用一个转义字符(ESCAPE character),如果查一个叫以”刘%” 开头的名字
select name from table where name like ‘刘%%’ escape ‘\’;

全部评论

相关推荐

牛客10001:问就是六个月,全国可飞,给钱就干
点赞 评论 收藏
分享
03-29 12:10
门头沟学院 C++
挣K存W养DOG:散漫消极者淘汰,一眼坑爹。实习几个月转正的时候说你加班太少,能力还行态度不够积极裁了,马上老实。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务