Google Associate Cloud Engineer Question 240
Single answerGoogle Cloud PlatformYou are working as a Google Cloud Engineer for a company that stores customer data in a Google Cloud SQL instance using MySQL. The company wants to retrieve specific customer details based on their email address for a marketing campaign. Which of the following queries will correctly retrieve the 'first_name' and 'last_name' from the 'customers' table where the 'email' matches a given email address?
- A
SELECT first_name, last_name FROM customers WHERE email = 'customer@example.com';
- B
SELECT first_name, last_name FROM customers WHERE 'email' = 'customer@example.com';
- C
SELECT first_name, last_name FROM customers WHERE email IS 'customer@example.com';
- D
SELECT first_name, last_name WHERE email = 'customer@example.com' FROM customers;
Show answer and explanation
Correct answer: A
Explanation
Option 1 is the correct SQL query that retrieves the 'first_name' and 'last_name' from the 'customers' table where the email matches 'customer@example.com'. It correctly uses the WHERE clause to filter records and the appropriate syntax for column selection.
- A. Correct.
This is the correct SQL syntax for selecting specific columns from a table with a WHERE clause filtering by the 'email' field.
- B. Incorrect.
In SQL, the column names should not be enclosed in single quotes. Single quotes are used for string literals.
- C. Incorrect.
The 'IS' keyword is not used for comparing string values in SQL. The '=' operator should be used instead.
- D. Incorrect.
The SQL syntax is incorrect here as the FROM clause must precede the WHERE clause.