P.S: This is just a study guide. The questions may not appear exactly like this.
Question 1
(TCO 6) The four main clauses of the SELECT statement must be coded in the following order.
1. SELECT, FROM, ORDER BY, WHERE
2. SELECT, WHERE, ORDER BY, FROM
3. SELECT, FROM, WHERE, ORDER BY
4. SELECT, ORDER BY, FROM, WHERE
Question 2
(TCO 6) Which operator would be most appropriate to determine books with a retail price in the range of $50 to $100?
1. LIKE
2. IN
3. BETWEEN
4. >
Question 3
(TCO 6) Which code returns the date field HIREDATE in the format: Friday, April 5th, 2015?
1. DATE_FORMAT(HIREDATE, ‘%W, %m %d, %Y’)
2. DATE_FORMAT(HIREDATE, ‘%a, %M %D, %Y’)
3. DATE_FORMAT(HIREDATE, ‘%W, %M %D, %Y’)
4. DATE_FORMAT(HIREDATE, ‘%a, %m %d, %y’)
Question 4
(TCO 6) Given a customer table with fields for firstname and lastname, which of the following will display the customer name as a single field in the format “Jones, Tom” with a heading?
1. SELECT CONCAT(lastname, firstname) as “Name” FROM customer;
2. SELECT CONCAT(firstname, lastname) as “Name” FROM customer;
3. SELECT CONCAT(lastname, ‘, ‘, firstname) as “Name” FROM customer;
4. SELECT CONCAT lastname ‘, ‘ firstname as “Name” FROM customer;
Question 5
(TCO 8) Given a table customer with fields firstname, lastname (both varchar) and custid (integer), which is a proper update command?
1. UPDATE customer SET firstname = ‘Joe’ WHERE custid = 22;
2. UPDATE customer REPLACE firstname = ‘Joe’ WHERE custid = 22;
3. UPDATE customer WHERE custid = 22 SET firstname = ‘Joe’;
4. UPDATE customer WHERE custid = 22 ALTER firstname = ‘Joe’;
Question 6
(TCO 6) Given a table orders with fields for orderid, orderdate, and shipdate, which query will display the ordered for only those orders that have shipped?
1. SELECT ordered FROM orders WHERE shipdate <> orderdate;
2. SELECT orderid FROM orders WHERE shipdate IS NOT NULL;
3. SELECT orderid FROM orders WHERE shipdate IS NULL;
4. SELECT orderid FROM orders;
Question 7
(TCO 6) Which WHERE clause will return data on all books with ‘JAVA’ anywhere in the title?
1. WHERE title LIKE ‘JAVA’
2. WHERE title LIKE ‘JAVA%’
3. WHERE title LIKE ‘%JAVA%’
4. WHERE title LIKE ‘%JAVA’
Question 8
(TCO 6) Given a books table with fields of title, cost, and retail, what if anything is wrong with the following query (assuming all fields exist)?
SELECT * FROM books ORDER BY retail WHERE cost > 20;
1. You must sort and filter on the same field.
2. You cannot use ORDER BY and WHERE in the same query.
3. The ORDER BY clause must always be last.
4. Nothing is wrong.
Question 9
(TCO 8) You can delete one or more rows in a table by using the _____ command.
1. UPDATE
2. DROP
3. DELETE
4. ALTER
Question 10
(TCO 6) Given a books table with fields: title, category (such as ‘SPORTS’), cost, retail; what condition will return books with a retail price under 30 in the ‘MYSTERY’ or ‘BIOGRAPHY’ categories?
1. WHERE retail < 30 AND category = ‘MYSTERY’ OR ‘BIOGRAPHY’
2. WHERE retail < 30 AND category = ‘MYSTERY’ OR category = ‘BIOGRAPHY’
3. WHERE retail < 30 AND (category = ‘MYSTERY’ OR category = ‘BIOGRAPHY’)
4. WHERE retail < 30 AND category IN ‘MYSTERY’ OR ‘BIOGRAPHY’