Unformatted text preview: column names are qualified by their relation names. 18 Note that the inner query can refer to E, but the outer query cannot
refer to D. EXISTS AND UNIQUE FUNCTIONS [NOT] EXISTS function • Check whether result of correlated nested query is empty or not
• EXISTS equivalent to (SELECT COUNT(*) … ) <> 0
custid name address phone Sale
saleid date custid SELECT name, phone
FROM Customer C
WHERE NOT EXISTS ( SELECT *
FROM Sale S
WHERE C.custid = S.custid);
• Note that columns selected in inner query are irrelevant. SQL function UNIQUE(Q) 19 • Returns TRUE if no duplicate tuples in result of query Q SUMMARY Complex SQL: •
• Self joins
Nested queries Relational algebra expressions can handle self joins and nested
queries with no additional operators 21 • Grouping, aggregations, and sorting require additional operators...
View Full Document
This document was uploaded on 02/07/2014.
- Spring '14