sql语句多条件筛选

where 子句关键字

  • select * from emp where comm is null ;
  • select * from emp where comm is not null;
  • 多条件使用and 关键字进行连接
  • select * from emp where comm is not null and comm>0 ;
  • (模糊查询)查询姓名中包含s 的, 以S开头的,或者以S结尾的 .% 表示任意东西。

select * from emp where ename like ‘%S%’ ;
-在模糊查询述

  • 指定第二个字符为A , _表示一个任意的字符 ,%表示任意多个字符
  • select * from emp where ename like ‘_A%’
  • 转义字符,_就表示为一个杠该怎么做呢?
  • escape’/’ 表示/可以作为转义字符了。赋予/的功能

可以使用in 关键字,也可以使用or 进行筛选,但是in中的内容只能为一个字段的值 select * from emp where job
in(‘SALESMAN’ , ‘ANALYST’ ,‘MANAGER’);
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_42859176/article/details/88910226