本章主要講解內連線,inner join子句將乙個表中的行於其他標表中的行進行匹配,並允許從兩個表中查詢包含列的行紀錄,一般出現在from子句之後。
desc employee;
desc department;
select e.fname, e.lname, d.name from employee e join department d;
select e.fname, e.lname, d.name from employee e join department d on e.dept_id = d.dept_id;
select e.fname, e.lname, d.name from employee e inner join department d on e.dept_id = d.dept_id;
select e.fname, e.lname, d.name from employee e inner join department d using (dept_id);
select e.fname, e.lname, d.name from employee e, department d where e.dept_id = d.dept_id;
select a.account_id, a.cust_id, a.open_date, a.product_cd from account a, branch b, employee e
where a.open_emp_id = e.emp_id
and e.start_date < '2007-01-01'
and e.assigned_branch_id = b.branch_id
and (e.title = 'teller' or e.title = 'head teller')
and b.name = 'woburn branch';
select a.account_id, a.cust_id, a.open_date, a.product_cd from account a inner join employee e
on a.open_emp_id = e.emp_id
inner join branch b
on e.assigned_branch_id = b.branch_id
where e.start_date < '2007-01-01'
and (e.title = 'teller' or e.title = 'head teller')
and b.name = 'woburn branch';
select a.account_id, c.fed_id from account a inner join customer c
on a.cust_id = c.cust_id where c.cust_type_cd = 'b';
select a.account_id, c.fed_id, e.fname, e.lname from account a inner join customer c
on a.cust_id = c.cust_id
inner join employee e
on a.open_emp_id = e.emp_id
where c.cust_type_cd = 'b';
select a.account_id, c.fed_id, e.fname, e.lname from customer c inner join account a
on e.emp_id = a.open_emp_id
inner join customer c
on a.cust_id = c.cust_id
where c.cust_type_cd = 'b';
select emp_id, assigned_branch_id from employee
where start_date < '2007-01-01'
and (title = 'teller' or title = 'head teller');
select branch_id from branch
where name = 'woburn branch';
select a.account_id, e.emp_id, b_a.name open_branch, b_e.name emo_branch
from account a inner join branch b_a
on a.open_branch_id = b_a.branch_id
inner join employee e
on a.open_emp_id = e.emp_id
inner join branch b_e
on e.assigned_branch_id = b_e.branch_id
where a.product_cd = 'chk';
select e.fname, e.lname, e_mgr.fname mgr_fname, e_mgr.lname mgr_lname
from employee e inner join employee e_mgr
on e.superior_emp_id = e_mgr.emp_id;
select e1.fname, e1.lname, 'vs' vs, e2.fname, e2.lname
from employee e1 inner join employee e2
on e1.emp_id != e2.emp_id
where e1.title = 'teller' and e2.title = 'teller';
select e1.fname, e1.lname, 'vs' vs, e2.fname, e2.lname
from employee e1 inner join employee e2
on e1.emp_id < e2.emp_id
where e1.title = 'teller' and e2.title = 'teller';
select a.account_id, a.product_cd, c.fed_id from account a inner join customer c
on a.cust_id = c.cust_id
where c.cust_type_cd = 'b';
select a.account_id, a.product_cd, c.fed_id from account a inner join customer c
on a.cust_id = c.cust_id
and c.cust_type_cd = 'b';
select a.account_id, a.product_cd, c.fed_id from account a inner join customer c
where a.account_id = c.cust_id
and c.cust_type_cd = 'b';
python第五章 Python學習(第五章)
記錄所有的名片字典 card list defshow menu 顯示資訊 print 50 print 歡迎使用 名片管理系統 v1.0 print print 1.新增名片 print 2.顯示全部 print 3.搜尋名片 print print 0.退出系統 print 50 defnew ...
第五章 雜湊
雜湊表adt,只支援二叉樹查詢所允許的一部分操作。比如插入,刪除,查詢等。那些需要元素間排序資訊的操作將不會得到支援。比如findmin,findmax和線性時間按排序順序列印整個表的操作時不支援的。雜湊函式在理想狀態是能將任何兩個不同的關鍵字對映到不同的單元,但是這是不可能,因為關鍵字是無窮的,但...
第五章 函式
第五章 函式 1 函式的定義 shell函式定義可以放在 bash profile 檔案中,也可以在使用該函式的指令碼中,還可以在命令列中 通過 source 或 執行bash profile檔案,使修改能夠立即生效 function 函式名 declare f 顯示定義的函式清單 export f...