Introduction to Database Systems Queries in SQL The select ...
Introduction to Database Systems Queries in SQL The select ...
Introduction to Database Systems Queries in SQL The select ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Intersection<br />
<strong>select</strong> name<br />
from employee<br />
<strong>in</strong>tersect<br />
<strong>select</strong> lastName as name<br />
from employee<br />
is equivalent <strong>to</strong><br />
<strong>select</strong> en.name<br />
from employee en, employee eln<br />
where en.name = eln.lastName<br />
67<br />
S<strong>in</strong>gle Block <strong>Queries</strong>: Exercises<br />
Consider a database about suppliers and parts with the follow<strong>in</strong>g schema:<br />
Supplier(sid, sname, address)<br />
Part(pid, pname, colour)<br />
Catalog(sid, pid, cost)<br />
Formulate the follow<strong>in</strong>g queries <strong>in</strong> <strong>SQL</strong>:<br />
1. F<strong>in</strong>d the names of suppliers who supply some red part.<br />
2. F<strong>in</strong>d the IDs of suppliers who supply some red or green part.<br />
3. F<strong>in</strong>d the IDs of suppliers who supply some red part and are based at 21<br />
George Street.<br />
68