4 - 18 Introduction to SQL Flashcards

1
Q

What does SQL stand for?

A

Structured Query Language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type of language is SQL?

A

SQL is a declarative language

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is SQL used for?

A

SQL is used for querying and updating tables in a relational database. It can also be used to create tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Give the basic syntax for the SELECT statement.

A

SELECT list the fields to be displayed
FROM list the table or tables the data will come from
WHERE list the search criteria
ORDER BY list the fields that the results are to be sorted on (default is Ascending order)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘=’

A

Equal to e.g. CDTitle = “Autumn”. Different implementations use single or double quotes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘>’

A

Greater than, eg.g. DatePublished > #01/01/2015#. The date is enclosed in quote marks or, in Access, # symbols

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘

A

Less than, e.g. Date Published < #01/01/2015#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘!=’

A

Not equal to, e.g. RecordCompany != “ABC”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘>=’

A

Greater than or equal to, e.g. DatePublished >= #01/01/2015#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘<=’

A

Less than or equal to, e.g. DatePublished <= #01/01/2015#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘IN’

A

Equal to the value within a set o values, RecordCompany IN (“ABC”, “DEF”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘LIKE’

A

Similar to, e.g. CDTitle LIKE “S%”. Finds shadows (wildcard operator varies and can be *)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘BETWEEN… AND’

A

Within a range, including the two values which define the limits, e.g. DatePublished BETWEEN #01/01/2015# AND #31/12/2015#

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘IS NULL’

A

Field does not contain a value, e.g. RecordCompany is NULL

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘AND’

A

Both expressions must be true for the entire expression to be judged true, e.g. DatePubished > #01/01/2015# AND RecordCompany = “ABC”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘OR’

A

If either or both of the expressions are true, the entire expression is judged true, e.g. RecordCompany = “ABC” OR RecordCompany = “DEF”. Equilvalent to RecordCompany IN (“ABC”, “DEF”)

17
Q

Give the meaning, example and any notes that may be included with the operator symbol being ‘NOT’

A

Inverts truth, ReordCompany NOT IN (“ABC, “DEF”)

18
Q

What does the SQL JOIN do?

A

JOIN provides an alternative method of combining rows from two or more tables, based on a common field between them.

19
Q

An example of SQL JOIN

A
SELECT Song.SongTitle, Artist.ArtistName, Song.MusicType
FROM Song
JOIN Artist
ON Song.ArtistID = Artist.ArtistID
WHERE Song.MusicType = "Art Pop"
20
Q

What is the correct SQL syntax to select data where more than one table is involved?

A

tablename.fieldname (The table name is optional unless the field name appears in more than one table.)