Final Review Flashcards
Find the error in this code:
SELECT name,
CASE
WHEN imdb_rating > 8 THEN ‘Oscar’
WHEN imdb_rating > 7 THEN ‘Good’
WHEN imdb_rating > 6 THEN ‘Fair’
FROM movies;
A. The column was not renamed.
B. Not enough WHEN/THEN statements.
C. Missing ELSE statement.
D. Missing END statement.
D. Missing END statement.
How would you query all the unique genres from the books table?
A. SELECT DISTINCT genres
FROM books;
B. FROM books
SELECT DISTINCT genres;
C. SELECT UNIQUE genres
FROM books;
D. SELECT genres
FROM books;
A. SELECT DISTINCT genres
FROM books;
T/F. IS NULL condition returns true if the field is empty.
True
What code would you add to this query to order colors by name alphabetically (Z to A)?
SELECT *
FROM colors
_________________;
A. ORDER BY name ASC
B. GROUP BY name ASC
C. ORDER BY name DESC
D. ORDER BY name
C. ORDER BY name DESC
What does the wildcard character % in the following SQL statement do?
SELECT *
FROM sports
WHERE name LIKE ‘%ball’;
A. It matches all sports that begin with ‘ball’.
B. It matches all sports that contain ‘ball’.
C. It matches all sports that have a pattern like ‘ball’, such as ‘b3ll’ and ‘b@ll’.
D. It matches all sports that end with ‘ball’.
D. It matches all sports that end with ‘ball’.
What is LIKE?
A. A clause used to bookmark columns that are frequently queried.
B. A clause used to select unique values from a table.
C. A special operator that can be used with the WHERE clause to search for a pattern.
D. A statement that allows us to create different outputs.
C. A special operator that can be used with the WHERE clause to search for a pattern.
What is LIMIT?
A. A clause that restricts our query results in order to obtain only the information we want.
B. A clause that is used to return unique values in the output.
C. A clause that lets you specify the maximum number of rows the result set will have.
D. A clause that lets you specify the maximum number of columns the result set will have.
C. A clause that lets you specify the maximum number of rows the result set will have.
What is ORDER BY?
A. A clause that allows you to select unique values.
B. An operator used with the WHERE clause.
C. A clause that sorts the result set alphabetically or numerically.
D. A clause that sorts the result set in alphabetical order only.
C. A clause that sorts the result set alphabetically or numerically.
What is the correct query to select only the cities with temperatures less than 35?
A. SELECT *
FROM cities
WHERE temperature < 35;
B. SELECT *
FROM cities
WHERE temperature = 35;
C. SELECT *
FROM cities;
D. SELECT *
FROM cities
WHERE temperature != 35;
A. SELECT *
FROM cities
WHERE temperature < 35;
What is the correct syntax to query both the name and date columns from the database?
SELECT __________
FROM album;
A. name & date
B. name, date
C. name; date
D. name + date
B. name, date
Which of the following is NOT a comparison operator in SQL?
A. ~
B. <
C. >=
D. !=
A. ~
Which operator would you use to query values that meet all conditions in a WHERE clause?
A. AND
B. OR
C. BETWEEN
D. LIKE
A. AND
Choose the correct explanation for the include statement in PHP.
A. include checks if a value is included in an array.
B. include brings in and evaluates code from one file to another.
C. include allows a global variable to be used within a function.
B. include brings in and evaluates code from one file to another.
Fill in the code so that “Great job!” prints to the terminal.
if (“cat” [_______] “dog”){
echo “Great job!”;
}
A. !== B. > C. ! D. = E. ===
A. !==
Fill in the code so that “Great job!” prints to the terminal.
if (1 [_________] 10){
echo “Great job!”;
}
A. = B. > C. & D. >= E. < F. ===
E.
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. < B. = C. === D. !== E. >
C. ===
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. >
B. <
C. !==
D. >=
D. >=
Fill in the code so that “Great job!” prints to the terminal.
if (10 [________] 10){
echo "Great job!";
}
A. > B. = C. < D. !== E. <=
E. <=
Fill in the code so that “Great job!” prints to the terminal.
if (10 [_____] 3){
echo “Great job!”;
}
A. > B. = C. & D. < E. <= F. ===
A. >
The following variables hold what type of values?
$first = TRUE; $second = FALSE;
A. Booleans
B. Floats
C. Strings
D. Arrays
A. Booleans
What will the following code output to the terminal?
$first = TRUE;
$second = FALSE;
$third = TRUE;
if ($first) {
if ($second){
echo "Option 1";
} else {
echo "Option 2";
}
} elseif ($third) {
echo "Option 3";
} else {
echo “Option 4”;
}
Option 4
What will the following code output to the terminal?
$happy = TRUE;
if ($happy) {
echo “I’m so happy right now!”;
}
A. TRUE
B. $happy
C. I’m so happy right now!
D. Nothing
C. I’m so happy right now!
What will the following code output to the terminal?
$letter = “h”;
switch ($letter) {
case “h”:
echo "h";
case “e”:
echo "e";
case “l”:
echo "l";
case “x”:
echo "l";
case “o”:
echo "o";
}
A. hel
B. helo
C. hello
D. h
hello
What will the following code output to the terminal?
$mood_color = “red”;
switch ($mood_color){
case "green": echo "You're feeling happy."; break; case "yellow": echo "You're feeling energized."; break; case "black": echo "You're feeling scared."; break; case "red": echo "You're feeling angry."; break;
}
A. You’re feeling energized.
B. You’re feeling scared.
C. You’re feeling happy.
D. You’re feeling angry.
D. You’re feeling angry.
Please enter your zip code:
A. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST['zip-it'] B. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST['$zip-it'] C. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST['zipCode'] D. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST['$zipCode'] E. When the processor executes zip-it.php, the zip code submitted by the user can be extracted from $_POST['zip code']Allow $studyTime hours for study
"); A.Allow 20 hours for study
B.Allow hours for study
C.Allow $studytime hours for study
D.Allow 0 hours for study
Allow 0 hours for study
How many hours do you sleep each night:
``` A. $_POST[$sleepHours] = 'sleepHours'; B. $_POST['sleepHours'] = $sleepHours; C. sleepHours = $_POST[$sleepHours]; D. $sleepHours = $_POST['sleepHours']; E. $sleepHours = $_POST[$sleepHours]; ```TOTAL COST: $number_format($total, 2)
"); A. The first and second statements are in the wrong order B. The second and third statements are in the wrong order C. The print statement will not display correctly. D. The value stored in $tax will be 0 when it should be 0.70TOTAL COST: $".number_format($total, 2)."
"); A. The first and second statements are in the wrong order B. The second and third statements are in the wrong order C. The print statement will not display correctly. D. The value stored in $tax will be 0 when it should be 0.70