SQL Types
Text and string types text — a string of any length, like Python str or unicode types. char(n) — a string of exactly n characters. varchar(n) — a string of up to n characters.
Numeric types integer — an integer value, like Python int. real — a floating-point value, like Python float. Accurate up to six decimal places. double precision — a higher-precision floating-point value. Accurate up to 15 decimal places. decimal — an exact decimal value.
Date and time types date — a calendar date; including year, month, and day. time — a time of day. timestamp — a date and time together.
Select Where
The syntax of the select statement with a where clause:
select columns from tables where condition ;
Columns are separated by commas; use * to select all columns.
Comparison Operators
The comparison operators in SQL are almost the same as the ones in Python: < for less than, > for greater than, != for not equal, <= for less than or equal, and so forth. One difference is that SQL uses = instead of == to represent equality. You can apply all the basic comparison operators to strings, numbers, dates, and other values.
Reminder: Dates in our databases will always be in the international standard format, e.g. '1999-12-31'. Make sure to put single quotes around dates.
Join
To join two tables, first choose the join condition, or the rule you want the database to use to match rows from one table up with rows of the other table. Then write a join in terms of the columns in each table.