日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

oracle之单行函数之多表查询值之课后练习

發布時間:2023/12/10 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 oracle之单行函数之多表查询值之课后练习 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
26. 多表連接查詢時, 若兩個表有同名的列, 必須使用表的別名對列名進行引用, 否則出錯!27. 查詢出公司員工的 last_name, department_name, cityselect last_name, department_name, cityfrom departments d, employees e, locations lwhere d.department_id = e.department_id and d.location_id = l.location_id28. 查詢出 last_name 為 'Chen' 的 manager 的信息. (員工的 manager_id 是某員工的 employee_id) 0). 例如: 老張的員工號為: "1001", 我的員工號為: "1002", 我的 manager_id 為 "1001" --- 我的 manager 是"老張" 1). 通過兩條 sql 查詢:select manager_idfrom employeeswhere lower(last_name) = 'chen' --返回的結果為 108select *from employeeswhere employee_id = 1082). 通過一條 sql 查詢(自連接):select m.*from employees e, employees mwhere e.manager_id = m.employee_id and e.last_name = 'Chen' 3). 通過一條 sql 查詢(子查詢): select *from employeeswhere employee_id = (select manager_id from employeeswhere last_name = 'Chen') 29. 查詢每個員工的 last_name 和 GRADE_LEVEL(在 JOB_GRADES 表中). ---- 非等值連接select last_name, salary, grade_level, lowest_sal, highest_salfrom employees e, job_grades jwhere e.salary >= j.lowest_sal and e.salary <= j.highest_sal30. 左外連接和右外連接select last_name, e.department_id, department_namefrom employees e, departments dwhere e.department_id = d.department_id(+)select last_name, d.department_id, department_namefrom employees e, departments dwhere e.department_id(+) = d.department_id理解 "(+)" 的位置: 以左外連接為例, 因為左表需要返回更多的記錄,右表就需要 "加上" 更多的記錄, 所以在右表的鏈接條件上加上 "(+)"注意: 1). 兩邊都加上 "(+)" 符號, 會發生語法錯誤!2). 這種語法為 Oracle 所獨有, 不能在其它數據庫中使用. 31. SQL 99 連接 Employees 表和 Departments 表1).select *from employees join departmentsusing(department_id)缺點: 要求兩個表中必須有一樣的列名.2).select *from employees e join departments don e.department_id = d.department_id3).多表連接select e.last_name, d.department_name, l.cityfrom employees e join departments don e.department_id = d.department_idjoin locations lon d.location_id = l.location_id 32. SQL 99 的左外連接, 右外連接, 滿外連接1).select last_name, department_namefrom employees e left outer join departments don e.department_id = d.department_id2).select last_name, department_namefrom employees e right join departments don e.department_id = d.department_id3).select last_name, department_namefrom employees e full join departments don e.department_id = d.department_id 1. 顯示所有員工的姓名,部門號和部門名稱。 a) select last_name,e.department_id,department_name b) from employees e,departments d c) where e.department_id = d.department_id(+)方法二: select last_name,e.department_id,department_name from employees e left outer join departments d on e.department_id = d.department_id 2. 查詢90號部門員工的job_id和90號部門的location_id a) select distinct job_id,location_id b) from employees e left outer join departments d c) on e.department_id = d.department_id d) where d.department_id = 90 3. 選擇所有有獎金的員工的 last_name , department_name , location_id , city select last_name,department_name,d.location_id,city from employees e join departments d on e.department_id = d.department_id join locations l on d.location_id = l.location_id where e.commission_pct is not null 4. 選擇city在Toronto工作的員工的 last_name , job_id , department_id , department_name select last_name , job_id , e.department_id , department_name from employees e ,departments d,locations l where e.department_id = d.department_id and l.city = 'Toronto' and d.location_id = l.location_id 5. 選擇指定員工的姓名,員工號,以及他的管理者的姓名和員工號,結果類似于下面的格式 employees Emp# manager Mgr# kochhar 101 king 100 select e1.last_name "employees",e1.employee_id "Emp#",e2.last_name"Manger",e2.employee_id "Mgr#" from employees e1,employees e2 where e1.manager_id = e2.employee_id(+)

?

總結

以上是生活随笔為你收集整理的oracle之单行函数之多表查询值之课后练习的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。