Murach's MySQL Flashcards

1
Q

What is the default date format used by MySQL?

A

YYYY-MM-DD

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

What are the two ways to express a ‘not equals’ comparison operator in a where clause?

A

<>

!=

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

Are character comparisons performed on a MySQL database case sensitive?

A

No

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

If you compare a null value to one of the comparison operators (=, <, > etc), the result will always be a null value. To test for null values, use the ______ clause instead.

A

IS NULL

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

Which two functions can be used to explicitly convert a data type?

A

CAST

CONVERT

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

What is the order of precedence for the three logical operators?

A
  1. NOT
  2. AND
  3. OR
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Are the two expressions used in the BETWEEN phrase for the range of values inclusive?

A

Yes

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

What are the two operators you can use to match a specific pattern or mask?

A

LIKE

REGEXP

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

The LIKE operator is an older operator that lets you search for simple string patterns. The mask can contain one or both of which wildcard symbols?

A

% (matches any string of zero or more characters)

_ (matches any single character)

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

Can searches using the LIKE or REGEXP operator use a table’s indexes?

A

No

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

Are masks used in the LIKE or REGEXP operators case sensitive?

A

No

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

What is the clause used to test whether a column contains a null value?

A

IS NULL

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

What is the clause used for specifying the sort order of a result set? And what is the default sequence (ASC or DESC)?

A

ORDER BY

ASC is the default, so it can be omitted if that’s the sort order required

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

What is a nested sort?

A

To sort by more than one column, you may simply list them in the ORDER BY clause separated by commas.

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

True or false: null values appear first in the sort sequence, even if using DESC.

A

True

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

Can you sort by a column in the base table even if it’s not included in the SELECT clause?

A

Yes

17
Q

Can you sort by a column alias?

A

Yes

18
Q

Can you use an arithmetic or string expression (e.g. CONCAT) to sort on?

A

Yes

19
Q

You cannot use the column number that corresponds to the result set to specify a sort order. True or false?

A

False

20
Q

Is it recommended to use column numbers to specify the sort order? Why or why not?

A

No it is not recommended because it is more difficult to read since you have to look at the SELECT clause to see what columns the numbers refer to, and also, if you add or remove columns, you may also have to change the ORDER BY clause to reflect the new column positions.

21
Q

What are the two possible arguments for the LIMIT clause? Which one is optional?

A

LIMIT [offset,] row_count

22
Q

How can you retrieve all of the rows from a certain offset to the end of the result set?

A

Code -1 for the row count.

23
Q

You can also join tables based on relationships not defined in the database. These are called…

A

Ad hoc relationships

24
Q

What is a qualified column name?

A

If two columns in a join have the same name, they must be qualified with the table name so MySQL can distinguish between them.

25
Q

Is the INNER keyword commonly used?

A

It is optional and seldom used.

26
Q

After you assign a table alias, do you have to use the alias in place of the original table name throughout the query?

A

Yes

27
Q

What’s the difference between a database and a schema in MySQL?

A

They are the same.

28
Q

Can you join tables from multiple databases? If so, how do you do it?

A

Yes, by qualifying each table that is from another database with the database name.

29
Q

A join condition can include two or more conditions connected by which operators?

A

AND

OR

30
Q

What is a self-join?

A

A join that joins a table to itself. They are rare but sometimes useful for retrieving data that can’t be retrieved any other way.

31
Q

Are aliases required in a self-join?

A

You must use aliases for the tables, and qualify each column name with the alias.