18 note that the inner query can refer to e but the

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

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 Customer 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 Aggregate functions Grouping Sorting 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online