5. Why SQL
๏Execute queries against a database
๏Retrieve data from a database
๏Insert records in a database
๏Update records in a database
๏Delete records from a database
๏Create new databases
๏Create new tables in a database
๏Create views in a database
6. Important SQL Commands
๏ถ SELECT - extracts data from a database
๏ถ UPDATE - updates data in a database
๏ถ DELETE - deletes data from a database
๏ถ INSERT INTO - inserts new data into a database
๏ถ CREATE DATABASE - creates a new database
๏ถ ALTER DATABASE - modifies a database
๏ถ CREATE TABLE - creates a new table
๏ถ ALTER TABLE - modifies a table
๏ถ DROP TABLE - deletes a table
๏ถ CREATE INDEX - creates an index (search key)
๏ถ DROP INDEX - deletes an index
9. WHERE Clause
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Example:
SELECT * FROM students
WHERE age='15';
10. Operators
๏ถ = Equal
๏ถ <> Not equal. Note: ( != )
๏ถ > Greater than
๏ถ < Less than
๏ถ >= Greater than or equal
๏ถ <= Less than or equal
๏ถ BETWEEN Between an inclusive range
๏ถ LIKE Search for a pattern
๏ถ IN To specify multiple possible values for a column
11. AND, OR and NOT
AND
SELECT * FROM table_name
WHERE condition1 AND condition2 AND condition3;
OR
SELECT * FROM table_name
WHERE condition1 OR condition2 OR condition3 ;
NOT
SELECT * FROM table_name
WHERE NOT condition;
12. ORDER BY
SELECT column1, column2, ...
FROM table_name
ORDER BY column ASC/DESC;
Example:
SELECT * FROM students ORDER BY id;
SELECT * FROM students ORDER BY id ASC;
SELECT * FROM students ORDER BY id DESC;