New Page
๐ SQL - Structured Query Language
๐ Creating and Using a Database
Commands:
-
CREATE DATABASE database_name; USE travel;
Explanation:
-
CREATE DATABASE: Creates a new database.
-
USE: Selects the database to work with.
๐ ๏ธ Creating Tables
planes table:
-
Stores flight routes.
-
numis the primary key. -
country_startandcountry_arrivalare origin/destination.
ftypes table:
-
Stores flight types.
-
plane_numis a foreign key referencingplanes(num).
โ๏ธ Inserting Data
-
Adds new records into the tables.
๐ Selecting Data
-
SELECT retrieves data.
-
AS renames columns.
-
ORDER BY sorts results.
๐งน Filtering Results
-
WHERE filters rows.
-
LIKE allows pattern matching.
-
AND/OR combine conditions.
๐ Updating Data
-
Updates data in existing rows.
๐๏ธ Deleting Data
-
Removes rows from a table.
๐ข Using BETWEEN
-
Filters values in an inclusive range.
๐ Joins (Combining Data from Tables)
LEFT JOIN:
-
All rows from
planes+ matching rows fromftypes.
RIGHT JOIN:
-
All rows from
ftypes+ matching rows fromplanes.
INNER JOIN:
-
Only rows that match in both tables.