Structured Query Language (SQL)

Last Update Unknown

Click here to view or download the cheat sheet for SQL

Creating a database table

To declare a foreign key, you would use:


CHAR is a fixed-length string (will always be a set length)

VARCHAR is a variable-length string (will be any number up to a certain length)


Insert Into

The INSERT INTO statement is used to insert new records in a table.


Update

The UPDATE statement is used to modify the existing records in a table.


Delete

The DELETE statement is used to delete existing records in a table.


Querying single table

The SELECT statement is used to select data from a database.

Fetch all columns from a specific table:

Fetch specific fields from a table:

Fetch product names sorted by their price in the default ASCending order:

Fetch product names sorted by their price in the DESCending order:

The WHERE clause is used to filter records and select the rows of a table you want.


Querying multiple tables