elect * from userInfo where age = 22;相当于:select * from userInfo where age >22;
5 、查询 age < 22 的记录
相当于:select * from userInfo where age <22;
6 、查询 age >= 25 的记录
相当于:select * from userInfo where age >= 25;
7 、查询 age <= 25 的记录
8 、查询 age >= 23 并且 age <= 26 注意书写格式
9 、查询 name 中包含 mongo 的数据 模糊查询用于搜索
相当于:%%select * from userInfo where name like ‘%mongo%’;
10 、查询 name 中以 mongo 开头的
相当于:select * from userInfo where name like ‘mongo%’;
11 、查询指定列 name 、age 数据
相当于:select name, age from userInfo;
当然 name 也可以用 true 或 false,当用 ture 的情况下河 name:1 效果一样,如果用 false 就是排除 name,显示 name 以外的列信息。
12 、查询指定列 name 、age 数据, age > 25
相当于:select name, age from userInfo where age >25;
13 、按照年龄排序 1 升序 -1 降序
14 、查询 name = zhangsan, age = 22 的数据
相当于:select * from userInfo where name = ‘zhangsan’ and age = ‘22’;
15 、查询前 5 条数据
相当于:selecttop 5 * from userInfo;
16 、查询 10 条以后的数据
相当于:select * from userInfo where id not in ( select top 10 * from userInfo );
发表评论