SELECT
SELECT reads data
SELECT builds a result from database data. In the simplest form, we specify which columns we want and which table they should come from.
SELECT id, name, email
FROM users;
You can think of the query result as a new temporary table: it has the selected columns and the rows returned by the database. A normal SELECT does not modify the source table.
You do not have to select every column
SELECT * selects every available column, but application code often benefits from listing only the columns that are actually needed. That makes the expected result clearer and reduces dependence on accidental changes to the table structure.
SELECT name AS user_name
FROM users;
With AS, a result column can be given an alias. The alias changes the name in the query result, not the column name in the table itself.
Check yourself
Exercise review
The mentor knows the solution and will help you reach it independently
Sign in to use the Mentor
The Mentor uses the current exercise and your conversation history.
Sign in
Review the key nuances and the answer after making your own attempt.
Sign in to view the solution
The solution and explanation are available after signing in.
Sign in