102-500 practice question 3 of 30
Which of the following SQL statements will select the fields name and address from the contacts table?
Full set: 233 questionsThe standard SQL syntax for selecting specific columns from a table is SELECT column1, column2, ... FROM tablename;. The column names must be separated by a comma. Parentheses are not used to enclose the column list in a simple SELECT statement, and omitting the comma between column names results in a syntax error.
A. SELECT (name, address) FROM contacts; is incorrect because parentheses are not used to group the column list in this context.
B. SELECT (name address) FROM contacts; is incorrect due to both the use of parentheses and the missing comma between field names.
D. SELECT name address FROM contacts; is incorrect because it lacks the required comma separator between the name and address fields.
1. PostgreSQL 14 Documentation, "Chapter 7. Queries", Section 7.3 "The Target List". It states, "The simplest kind of target list is ... A second kind of target list consists of a comma-separated list of expressions".
2. MySQL 8.0 Reference Manual, "13.2.13 SELECT Statement". The syntax shown is SELECT selectexpr [, selectexpr] ... FROM tablereferences. This explicitly shows the comma-separated list of expressions (columns).
3. Ramakrishnan, R., & Gehrke, J. (2003). Database Management Systems (3rd ed.). McGraw-Hill. Chapter 5, "SQL: The Query Language", Section 5.2 "The Basic Form of an SQL Query", page 143, illustrates the SELECT [DISTINCT] select-list FROM from-list WHERE qualification syntax, where select-list is a list of column names separated by commas.
Keep practicing
Take the free 102-500 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other 102-500 practice questions
- Question 1What output is produced by the following command sequence? echo ‘1 2 3 4 5 6’ | while rea…
- Question 2Which command will set the local machine's timezone to UTC?
- Question 4Which of the following commands can remove a user from a group?
- Question 5Where are user specific crontabs stored?
- Question 6Which of the following crontab entries will execute myscript at 30 minutes past every hou…
- Question 8Which file, when using Sendmail or a similar MTA system, will allow a user to redirect al…
