Write a Basic Query Flashcards
A SQL query is a request for ___________ ?
Information.
Update 10/30/21, 3.3
Is SQL a declarative or imperative programming language?
Declarative (3.6)
We describe the result we want, but we can’t control how the result is generated. (3.6)
Name that Clause!
List the columns that should appear in your result grid.
The SELECT Clause
3.5
Name that Clause!
Specify the data sources used in your query, typically tables.
The FROM Clause
3.5
What is a query also know as?
A SELECT Statement.
3.5
SQL queries must be written with their clauses in what order?
- SELECT
- FROM
- WHERE
- GROUP BY
- HAVING
- ORDER BY
(3.5)
SQL processes its clauses in what order?
- FROM
- WHERE
- GROUP BY
- HAVING
- SELECT
- ORDER BY
(3.5)
What does the asterisk mean in the following syntax?
SELECT *
FROM TableName
The asterisk (*) means “all columns,” and we have not limited the rows returned.
(3.7)
List and define the two types of comments?
- Line Comments - start with a double-dash ( – ), which will cause the rest of the line to become a comment.
- Block Comments - start with a forward-slash followed by an asterisk ( /* ), which will cause all text to be treated as a comment until it reaches an asterisk followed by a forward slash ( */ )
(3.7)
Do comments have to be on their own line?
Comments can start at any point during the query, on their own line or not.
(3.7)
How do comments provide a method of troubleshooting?
They can be used to temporarily disable sections of code. This can make it easier to selectively focus your attention on a certain section of code.
(3.8)
What does it mean to “comment out” a section of code?
Putting a section of code in a comment enables easily re-adding the code later by uncommenting the section of code: undoing the commenting syntax.
(3.8)
Which type of comment can be used to comment out code?
Both line comments and block comments can be used to comment out code.
(3.8)
How can you control the order the results are returned?
By using the ORDER BY clause.
3.11
What is the default order of the ORDER BY clause?
Ascending order.
3.11