首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

【数据库设计和SQL基础语法】--查询数据--过滤

运算符说明示例等于 (=)用于检索列中与指定值相等的行。示例:SELECT * FROM employees WHERE department_id = 1;不等于 (<>, !=)用于检索列中与指定值不相等的行。示例:SELECT * FROM products WHERE category <> 'Electronics';大于 (>)用于检索列中大于指定值的行。示例:SELECT * FROM orders WHERE total_amount > 1000;小于 (<)用于检索列中小于指定值的行。示例:SELECT * FROM students WHERE age < 18;大于等于 (>=)用于检索列中大于或等于指定值的行。示例:SELECT * FROM employees WHERE salary >= 50000;小于等于 (<=)用于检索列中小于或等于指定值的行。示例:SELECT * FROM products WHERE price <= 50;这些比较运算符可以在WHERE子句中灵活使用,帮助过滤出满足特定条件的数据。在实际应用中,可以根据需要组合多个条件来实现更复杂的数据过滤。

01
您找到你想要的搜索结果了吗?
是的
没有找到

MyBatis : Mapper 接口以及 Example 使用实例、详解

方法 功能说明 int countByExample(UserExample example) thorws SQLException 按条件计数 int deleteByPrimaryKey(Integer id) thorws SQLException 按主键删除 int deleteByExample(UserExample example) thorws SQLException 按条件查询 String/Integer insert(User record) thorws SQLException 插入数据(返回值为ID) User selectByPrimaryKey(Integer id) thorws SQLException 按主键查询 ListselectByExample(UserExample example) thorws SQLException 按条件查询 ListselectByExampleWithBLOGs(UserExample example) thorws SQLException 按条件查询(包括BLOB字段)。只有当数据表中的字段类型有为二进制的才会产生。 int updateByPrimaryKey(User record) thorws SQLException 按主键更新 int updateByPrimaryKeySelective(User record) thorws SQLException 按主键更新值不为null的字段 int updateByExample(User record, UserExample example) thorws SQLException 按条件更新 int updateByExampleSelective(User record, UserExample example) thorws SQLException 按条件更新值不为null的字段

01

oracle--单表查询

---单表的查询学习 --查询表的所有数据 select * from 表名;*代表所有 select * from emp; --查询表中指定字段的值 select 字段名1,字段名2,...from表名 select empno from emp; select empno,ename from emp; --给查询结果中的字段使用别名 --在字段名后使用关键字 字段名 as "别名" --作用:方便查看查询结果 --注意:as关键字可以省略不写,别名中没有特殊字符双引号也可以省略不写。 select empno 员工编号,ename"员工 姓名",job as 工作,mgr as "领导编号" from emp; --连接符:select 字段名||'字符'||字段名||..... from 表名 --||为sql语句的字符链接符,使用在select和from之间 --字符链接格式为 字段名||'字符'||字段名 --注意:一个拼接好的连接在结果集中是作为一个新的字段显示,可以使用别名优化字段显示。 select empno||'的姓名是'||ename as"信息",job||'哈哈'||mgr from emp; --去除重复 select distinct 字段名,字段名,...fromn 表名 ---注意:去除重复的规则是按照行进行去除的,多行数据完全相同取其一 select distinct job ,mgr from emp; --排序 --单字段排序 --select * from 表名 order by 字段名 asc 升序排序 asc可以省略不写 --select * from 表名 order by 字段名 desc 降序序排序 --多字段排序 --select * from emp order by 字段名1,字段名2... --先按照字段1排序,如果字段1的值相同,则按照字段2排序,.... select * from emp order by empno desc--单字段排序 降序 select empno,ename,job from emp order by ename asc--单字段排序 升序 select * from emp order by empno,ename--多字段排序 --字段的逻辑运算 --select关键字和from关键字之间的字段可以直接进行四则运算 --字段与字段之间也可以直接进行运算 --注意:字段值为数值类型 select * from emp select empno,ename,job,sal*2+1000,sal+comm from emp ----------------------------------------------------------------- --使用where子句查询筛选 --select 字段名,字段名,...from表名 where 筛选条件 --单筛选条件 --使用运算符进行筛选 =,>,>=,<,<=,<> 单个条件中 --注意:如果条件中的值为字符,必须使用单引号括起来 --查询所有的员工的工资信息 select empno,ename,sal+comm as 薪资 from emp --查询SMITH的个人信息 select * from emp where ename='SMITH' --查询SMITH的薪资信息,逻辑运算符= select empno,ename,sal,sal+comm from emp where ename='SMITH' --查询工资大于1000的员工信息,逻辑符> select * from emp where sal>'2000' --查询工资不等于3000的员工信息 select * from emp where sal<>3000 order by sal --练习: --查看工资等于1250的员工信息

01
领券