Introduction to Select Statements Flashcards
What is a SELECT statement?
A SELECT statement retrieves columns of data from one or more tables or views.
What are some ways you can use the SELECT statement?
It can list all columns within a table. It can list specific columns in a table. You can use the SELECT statement to list specific columns and then filter rows with the WHERE statement. You can display columns and list data from multiple tables using a JOIN statement.
What order will your columns be displayed in your table?
The order that you list them out in your SELECT statement.
If your column has a space in it, like a column that says “First Name,” how would you write it in your SELECT statement?
You would use brackets.
SELECT
VersionDate
, [First Name]
How do you display all the columns in a table in your result set?
SELECT *
Why is it not good practice to use SELECT *?
Because it decreases performance. It’s better to explicitly define your columns in the SELECT statement.
What is a SQL statement?
It is a complete command that performs an action on a database and can include multiple clauses.
How do you list the Table Name Syntax in the FROM clause?
server.database.schema.object
What does the FROM clause identify?
The table where data will be pulled. If you are pulling from multiple tables, you will identify the relationships in the FROM clause.
What is an SQL Clause?
It is a part of a SQL statement that specifies a condition or operation. For example, the FROM clause.
What does the WHERE clause do?
It filters the rows of a result set. It can’t filter from tables not listed in the FROM clause. However, it can filter columns not present in the SELECT clause.
What does a simple WHERE condition consist of?
It consists of a column, an operator, and a value.
When do you need to enclose a value in single quotes in a WHERE clause?
Text and Dates entries need quotes.
Which clause type can you compare columns against each other?
In the WHERE clause. WHERE StartDate = EndDate
What is the not equal operator in a WHERE statement?
<>