1. ์ฑ ์ ์ฃผ๋ฌธํ ๊ณ ๊ฐ์ ๋ณด์ ์ฃผ๋ฌธ์ ๋ณด
select *
from cust, orders
where cust.cid = orders.cid;
2. ์ฃผ๋ฌธ๋ ์ฑ ์ ์ ๋ณด์ ์ฃผ๋ฌธ์ ๋ณด
select *
from book, orders
whrer book.bid = orders.bid;
3. ์ฃผ๋ฌธ์ ๋ณด๋ฅผ ๋ณด์ด๊ธฐ(oid, cname, title, price)
select oid, cname, title, price
from cust, orders, book
where cust.cid = orders.cid and book.bid = orders.bid;
4. ๊ณ ๊ฐ์ ์ฃผ๋ฌธ์ ๋ณด ๋ณด์ด๊ธฐ ๋จ, ์ด๋ฆ์์ผ๋ก ๋ด๋ฆผ์ฐจ์ํด์(oid, cname)
select oid, cname
from cust inner join orders on cust.cid = orders.cid
order by cname desc;
select oid, cname
from cust, orders
where cust.cid = orders.cid
order by cname desc;
5. ๊ณ ๊ฐ๋ณ ์ฃผ๋ฌธ์ด์ก์ ๋ณด์ด๊ธฐ(cid, sum(price))
select cid, sum(price)
from book, orders
where book.bid = orders.bid
group by cid;
6. ๊ณ ๊ฐ์ ์ฃผ๋ฌธ์ ๋ณด๋ฅผ ๋ณด์ด๋, ์ฃผ๋ฌธํ์ง ์์ ๊ณ ๊ฐ์ ๋ณด๋ ๋ณด์ด์ธ์.(oid, cname)
select oid, cname
from cust left outer join orders on cust.cid = orders.cid;
7. ์ฃผ๋ฌธ์ ๋ณด๋ฅผ ๋ณด์ด๋ ํํดํ ๊ณ ๊ฐ์ ์ฃผ๋ฌธ์ ๋ณด๋ ๋ณด์ด์ธ์(oid, cname)
select oid, cname
from cust right outer join orders on cust.cid = orders.cid;
8. ๊ณ ๊ฐ์ ์ฃผ๋ฌธ์ ๋ณด๋ฅผ ๋ณด์ด๋, ์ฃผ๋ฌธํ์ง ์์ ๊ณ ๊ฐ์ ์ ๋ณด๋ ๋ณด์ด๊ณ , ํํดํ ๊ณ ๊ฐ์ ์ฃผ๋ฌธ์ ๋ณด๋ ๋ณด์ด์ธ์(oid, cname)
select oid, cname
from cust left outer join orders on cust.cid = orders.cid
union
select oid, cname
from cust right outer join orders on cust.cid = orders.cid;
728x90
๋ฐ์ํ
0