1 of 60

CS-10337 – Applied Database Technologies� Lecture 4

By Prof. Rafael Orta

2 of 60

Wayground

3 of 60

Last class we covered

  • Lab assignment #1
  • Relationships
  • Referential Integrity
  • Quiz #1

4 of 60

Agenda

  • Retrieving data
  • Use of joins

5 of 60

Retrieving Data

6 of 60

Retrieving all the rows

7 of 60

Retrieving selected columns

8 of 60

Retrieving selected columns

9 of 60

Using between

10 of 60

Using the distinct clause

11 of 60

Calculated values and Alias

12 of 60

Order of Operations

13 of 60

Arithmetic Operations

14 of 60

Column Aliases

15 of 60

Column Aliases

16 of 60

Using Functions

17 of 60

Using functions

18 of 60

Comparison Operators

19 of 60

Use of the where clause

20 of 60

Use of the like function

21 of 60

The in and between clause

22 of 60

Using regular expressions

23 of 60

Using regular expressions

24 of 60

Using regular expressions

25 of 60

Using NULL

26 of 60

Using NULL

27 of 60

Order By Clause

28 of 60

Order By Clause

29 of 60

Use of the limit clause

30 of 60

Working with Dates

31 of 60

Using Variables

32 of 60

Supplemental Video(s)

33 of 60

Supplemental Reading

34 of 60

Knowledge Check

Which of the following statements about SQL filtering is true?

A. The IN clause can only accept numeric values, not strings.�B. The BETWEEN operator excludes the boundary values.�C. The LIKE operator can use % for multiple characters and _ for a single character.�D. The DISTINCT keyword sorts rows alphabetically by default.

Correct Answer: C

35 of 60

Use of Joins

36 of 60

Simple Inner joins

37 of 60

Simple Inner joins

38 of 60

Simple Inner joins

39 of 60

Simple Inner joins

40 of 60

Simple Inner joins

41 of 60

Simple Inner joins

42 of 60

Simple Inner joins

43 of 60

Outer vs Inner Joins

44 of 60

Outer Joins

45 of 60

Outer Joins

46 of 60

Left Outer Joins

47 of 60

Right Outer Joins

48 of 60

Joins using the USING Keyword

49 of 60

Natural Joins

50 of 60

Cross Joins

51 of 60

Cross Joins

52 of 60

Attendance

53 of 60

Unions

54 of 60

Unions

55 of 60

Unions

56 of 60

Supplemental Video(s)

57 of 60

Supplemental Reading

58 of 60

Knowledge Check

Which of the following statements about MySQL joins is true?

A. INNER JOIN returns all rows from the left table even when there’s no match.�B. LEFT JOIN returns all rows from the left table and the matching rows from the right; non-matches have NULL on the right.�C. NATURAL JOIN requires an explicit ON clause listing the join columns.�D. CROSS JOIN filters rows based on a join predicate.

Correct Answer: B

59 of 60

Reference Material used in this presentation

  • Murach’s MySQL 3rd Edition.
  • Fundamentals of Database Systems, 7th Edition by Elmasnri
  • Proprietary Material by the author.
  • Material from Professor Jack Mayers.
  • Material from Professor Phillip Quinn.

60 of 60