Skip to content

Database

Chris Nodel edited this page Apr 12, 2024 · 9 revisions

Queries

To perform directly through the following syntax:

  • SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME];

To select for specific criteria use the following syntax

  • SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] WHERE [BOOLEAN STATEMENT*];

To group by a specific criteria use the following syntax

  • SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] GROUP BY [COLUMN];

To order the query results in ascending or descending order use the following syntax:

  • SELECT [COLUMN1, COLUMN2... OR * for ALL Columns] FROM [TABLE_NAME] ORDER BY [COLUMN] AESC/DESC*

NOTES: These queries are not mutually exclusive from one another and can be combined to create more specific queries.

Sample Boolean statement:

x = y, x > y, x < y

boolean operators include

AND, OR, NOT, LIKE

By default order by sorts elements in ascending order so AESC is not strictly necessary, however to order by descending order DESC is necessary.

For more specific SQL Queries such as those that use JOIN see here

Item Additions

To perform insertions into the database use the following syntax:

INSERT INTO [TABLE_NAME], (COLUMN1, COLUMN2, ... ) VALUES (VALUE1, VALUE2, ...);

To perform multiple insertions use similar syntax as follows:

INSERT INTO [TABLE_NAME], (COLUMN1, COLUMN2, ... ) VALUES (VALUE1, VALUE2, ...), (VALUE3, VALUE4, ...), ... ;

Notes:

the values must coincide with the listed columns for example you cant insert more values than there are columns nor can you insert a string value into a column that accepts all integers.

some columns have a constraints such that they cannot be null meaning an insertion cannot omit these columns.

Item Removals

To remove items from a database use the following syntax:

DELETE FROM [TABLE] WHERE [BOOLEAN STATEMENT];

Notes:

the omission of the conditional statement results in the removal of all items from the table.

Database Setup

Clone this wiki locally