next up previous
Next: Aggregate Functions Up: SQL Previous: Duplicate Tuples

Set Operations

  1. SQL has the set operations union, intersect and except.
  2. Find all customers having an account.

     select distinct cname
    

    from depositor

  3. union: Find all customers having a loan, an account, or both. branch.

     (select cname
    

    from depositor)

    union

    (select cname

    from borrower)

  4. intersect: Find customers having a loan and an account.

     (select distinct cname
    

    from depositor)

    intersect

    (select distinct cname

    from borrower)

  5. except: Find customers having an account, but not a loan.

     (select distinct cname
    

    from depositor)

    except

    (select cname

    from borrower)

  6. Some additional details:


Osmar Zaiane
Fri May 22 19:39:12 PDT 1998