1z0-082 Exam QuestionsBrowse all questions from this exam

1z0-082 Exam - Question 14


Examine the description of the CUSTOMERS table:

You want to display details of all customers who reside in cities starting with the letter D followed by at least two characters.

Which query can be used?

Show Answer
Correct Answer: A

The correct query should use the LIKE clause to find cities that start with 'D' followed by at least two characters. The underscore (_) in SQL represents any single character, and the percent sign (%) represents zero or more characters. Therefore, the correct pattern to match cities starting with 'D' followed by at least two characters is 'D__%'. However, among the provided options, option A ('SELECT * FROM customers WHERE city LIKE 'D_%';') is the closest one, as it uses the LIKE clause and the correct syntax, even though it doesn't strictly enforce the condition of having at least two characters following 'D'. The other options either misuse the LIKE clause or the equality operator, or don't match the described criteria at all.

Discussion

5 comments
Sign in to comment
NowOrNeverOption: A
Nov 3, 2020

there is no valid answer here correct would be (followed by at least two characters): SELECT * FROM EMPLOYEES WHERE FIRST_NAME LIKE 'D__%'; but A is the most correct

elvegaa
Nov 13, 2020

You're right. Also, there's no valid answer because double quotes are used in the LIKE clause

SimoneF
Nov 24, 2020

I assume there's been some issue with copy-pasting the text, and the first ' as been replaced with "~ I think it's supposed to be A anyway, but you're certainly correct that they're all wrong written as they are.

EkosOption: A
Oct 23, 2020

yes, A is the correct answer

algerianphoenix
May 15, 2022

No correct answer here, the correct SQL query would be: SELECT * FROM EMPLOYEES WHERE FIRST_NAME LIKE 'D__%'; Notice there 2 underscores;

saad3577
Sep 28, 2022

the table name CUSTOMERS table, from where you came with EMPLOYEES ? ex: WHERE CustomerName LIKE 'a_%' --> Finds any values that start with "a" and are at least 2 characters in length https://www.w3schools.com/sql/sql_like.asp

nautil2Option: A
Sep 15, 2023

A is the most close to be valid answer. LIKE must be used when comparing text strings (B, D are incorrect), metacharacter % must be used to accept strings of variable length (C is incorrect), metacharacter _ stands for any character. Underscore _ should be doubled to fulfill the request of two additional characters that follows initial letter D, so the query should end with LIKE ‘D__%’

valiantvimalOption: A
Apr 25, 2024

Many comments here saying that 2 underscores must be there but I think single underscore is enough because 'D_%' means that after underscore % means that there must be a character or more to display the result. Hence, A option is accurate and correct.