SQL Flashcards
SQL
Structured Query Languages
SQL Databases
- MySQL
- Microsoft SQL Server
- BigQuery [Google Data Cloud]
Syntax
A set of guidelines unique to every programming language. This structured language includes words, symbols, and punctuation, as well as their proper placement.
SQL Query Syntax
SELECT
FROM
WHERE
SELECT
Use SELECT to choose the columns you want to return.
FROM
Use FROM to choose the tables where the columns are located.
WHERE
Use WHERE to filter for certain information.
Query
A request for data or information from a database.
Semicolon (;)
This is known as a statement terminator. It’s used to end a statement. Though part of the American National Standards Institute (ANSI) SQL-92’s recommended common syntax standard, it isn’t universally used or enforced by all databases.
Comments
You can place comments alongside a SQL query to help you remember what the name represents. This is done using either dashes (–), /* and / or a hash symbol (#). Not all databases support the use of / and */ and the hash symbol.
/* and */
Used to place a comment alongside a SQL query for name referencing. Not used by all databases.
#
Used to place a comment alongside a SQL query for name referencing. Not used by all databases. [MySQL doesn’t recognise the #.]
–
Used to place a comment alongside a SQL query for name referencing. Most commonly used.
SELECT*
The asterick selects all of the columns in a table. Use sparingly and with caution.
Aliases
You can assign a new name to a column using the AS command. An example of this would be “field1 AS last_name”. An alias doesn’t change the actual name of a column in a database.