標籤:建議 weight dep 查詢語句 eth gpo 表示 運算 esc
where語句的查詢
--where子句--查詢部門編號是10的所有的員工select * from emp where deptno = 10;--查詢部門中工資是3000的員工select * from emp where sal = 3000;--找到部門中編號是 7788的員工select * from emp where empno = 7788;--查詢姓名為SCOTT的員工所有資訊--在使用where 查詢條件,字串是單引號而且區分大小寫select * from emp WHERE ename = ‘SCOTT‘;--查詢所有在日期是1981年5月1日入職的員工資訊--select * from emp where hiredate = ‘1981-5-1‘;--日期預設格式是 DD-MON-YYYY 查詢條件按照日期來,日期也要加單引號select * from emp where hiredate = ‘1/5月/1981‘;--查詢工資大於3000的員工select * from emp where sal>=3000; ---注意:sal=>3000 是錯誤的!資料庫將不認識此符號!--查詢工資範圍在1500-3000的員工所有資訊select * from emp where sal>=1500 and sal<=3000;-- between..and...表示介於 兩個值之間,包涵邊界值select * from emp where sal between 1500 and 3000;--查詢姓名是KING和SCOTT的詳細資料select * from emp where ename = ‘KING‘ or ename =‘SCOTT‘;--IN 表示出現在集合中的記錄 select * from emp where ename in (‘KING‘,‘SCOTT‘);--查詢工資不等於3000的員工資訊select * from emp where sal <> 3000; --method1select * from emp where sal !=3000; --method2select * from emp where not sal = 3000; --method3 取反運算--查詢所有沒有提成的員工的資訊-- is null 表示某個欄位為空白 不為空白 is not nullselect * from emp where comm is not null;-- 取反的意思 where not comm is nullselect * from emp where not comm is null;-- not 也可以代表取反的意思select * from emp where ename not in (‘KING‘,‘SCOTT‘);--查詢所有姓名以s開頭的員工資訊-- 使用 like 和 萬用字元-- 兩個萬用字元 %代表0個或者多個字元 _一個字元select * from emp where ename like ‘%S‘; ---字元(或是‘ ‘)裡面嚴格區分大小寫。建議全部大寫書寫語句!--查詢名字中帶有0的select * from emp where ename like ‘%O%‘;--查詢第二個字母是L的員工的所有資訊select * from emp where ename like ‘_L%‘;--查詢員工姓名中帶有_的所有的資訊--ESCAPE ‘’ 相當於自己定義一個轉義符select * from emp where ename like ‘%a_%‘ ESCAPE ‘a‘;
Oracle條件查詢語句-where