SQL查询技巧:WHERE子句中等值与非等值条件应用.pdfVIP

  • 0
  • 0
  • 约1.45千字
  • 约 4页
  • 2026-02-11 发布于北京
  • 举报

SQL查询技巧:WHERE子句中等值与非等值条件应用.pdf

1.where子句

用于进行条件过滤

1.1等值条件

a)查询10部门所有员工的信息

选择*从emp其中deptno=10;

b)查询SCOTT的详细信息

select*fromempwhereename=scott;✖

字符串必须加单引号,而且大小写敏感

select*fromempwhereename=SCOTT;

c)查询在1982‑01‑23入职的员工信息

日期必须用单引号括起来;日期

格式必须是:DD‑MM月‑YY

select*fromempwherehiredate=23-1月-82;

1.2非等值条件

a)查询工资在1500到3000之间的员工信息

1.where子句

用于进行条件过滤

1.1等值条件

a)查询10部门所有员工的信息

select*fromempwheredeptno=10;

b)查询SCOTT的详细信息

select*fromempwhereename=scott;✖

字符串必须加单引号,而且大小写敏感

select*fromempwhereename=SCOTT;

c)查询在1982-01-23入职的员工信息

日期必须用单引号括起来;

日期格式必须是:DD-MM月-YY

select*fromempwherehiredate=23-1月-82;

1.2非等值条件

a)查询工资在1500到3000之间的员工信息

ween...and...表示一个范围,包含边界

选择*从员工表哪里薪水=1500并且薪水=3000;

select*fromempwheresalween1500and3000;

b)查询SCOTT和KING的详细信息

select*fromempwhereename=SCOTTorename=KING;

select*fromempwhereenamein(SCOTT,KING);

c)查询所有员工的信息,排除20部门

选择*从emp哪里deptno!=20;

选择*从emp哪里deptno20;

ween...and...表示一个范围,包含边界

select*fromempwheresal=1500andsal=3000;

select*fromempwheresalween1500and3000;

b)查询SCOTT和KING的详细信息

select*fromempwhereename=SCOTTorename=KING;

select*fromempwhereenamein(SCOTT,KING);

c)查询所有员工的信息,排除20部门

select*fromempwheredeptno!=20;

select*fromempwheredeptno20;

文档评论(0)

1亿VIP精品文档

相关文档