理系学生日記

おまえはいつまで学生気分なのか

忍者TOOLS

Chapter 6: Working with Sets

6-1

A={L, M, N, O, P}
B={P, Q, R, S, T}

  • A union B = {L, M, N, O, P, Q, R, S, T}
  • A union all B = {L, M, N, O, P, P, Q, R, S, T}
  • A intersect B = {P}
  • A except B = {L, M, N, O, Q, R, S, T}

6-2

mysql> SELECT fname, lname FROM individual
    -> UNION
    -> SELECT fname, lname FROM employee;

6-3

mysql> SELECT fname, lname FROM individual
    -> UNION
    -> SELECT fname, lname FROM employee
    -> ORDER BY lname;