An introduction to rules for keywords, strings, identifiers, and comments.
Though keywords are not case-insensitive, it’s good practice to put them in all caps.
Strings may be surrounded by either single or double quotes and are always case-sensitive. There are special non-alphanumeric values which can be included in a string if they are escaped. They are: tab, line break, hard return, form feed, single quote and double quote. The syntax for the escaped forms is as follows: \t \b \r \f ', and ".
You can get into trouble by copying and pasting from other applications which might use smart quotes as they will cause your query to break.
The identifier, or name, of any object in a query may contain only alphanumeric characters and underscores. Identifiers can’t start with a number and can’t be keywords. It is possible to have identifiers with non-alphanumeric characters if they are enclosed in backticks
`. Identifiers which are not enclosed are not case-sensitive. Identifiers which are enclosed are case-sensitive.
Another useful SQL feature is having the ability to create comments that are stored with saved queries. Comments can be added to any line in a query by putting two dashes at the end of the line (at the beginning of the line if it’s otherwise blank). Anything following the dashes and before a new line is a comment. For example if we wanted to comment the query we ran for the special columns section we could write:
--This query returns all columns for the specified table as well as the two data.world specific columns row_index and row_address. SELECT product, sales_price, row_index, row_address FROM products--any table works --You must manually list all the columns you would like included.
An introduction to multi-tables.