Oracle條件查詢語句-where

來源:互聯網
上載者:User

標籤:建議   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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.