CompTIA Tech+ (FC0-U71)Data and Database FundamentalsMedium
A technician needs to write a SQL statement that retrieves every column of data from a table named Employees. Which statement is correct?
- AGET ALL FROM Employees;
- BSELECT Employees FROM *;
- CRETRIEVE * Employees;
- DSELECT * FROM Employees;
Show answer & explanationAnswer & explanation
Correct answer: D. SELECT * FROM Employees;
In SQL, the asterisk (*) is a wildcard meaning 'all columns,' and the correct syntax to retrieve all data is SELECT * FROM tablename;. The other options use invalid SQL keywords and syntax.
Why the other options are wrong
- A. GET ALL is not a valid SQL keyword.
- B. This reverses table and column placement incorrectly.
- C. RETRIEVE is not a valid SQL command.
SQL SELECT Statement
SELECT is the SQL command used to query and retrieve data from a database table; the asterisk (*) wildcard retrieves all columns.
- Basic syntax: SELECT columns FROM table;
- * wildcard means all columns
- Statements typically end with a semicolon
Memory trick: SELECT * FROM = 'Select Everything From' the table