SQL Basics

SQL Architecture:

SQL Query Syntax:

Select name, price From products Where id=1; This grabs the item name and price (columns) from the product table where the id(row) is 1.

You can also select constants: Select 22, 'string', 0x12;

Unions

This combines multiple sql queries (requests). <Select statement> Union <Select statement>;

Dinstinct and All

Use Distinct to filter out duplicate entries: Select DISTINCT <unique item> <statement>; When using Union it automatically implies Distinct. You can stop that by using ALL: <Select statement> Union ALL <Select statement>;

Comments

Ether 2 dashes followed by a space or a hash -- #

Last updated