SQL Basics Study Notes
This document contains original, concise notes prepared for learning and revision. You may upload/share it only if the
platform rules allow educational notes and you are comfortable sharing it publicly.
Database Concepts
• A database stores related data in an organized form.
• A table contains rows and columns.
• A primary key uniquely identifies each row.
• A foreign key connects one table with another table.
Basic Commands
• CREATE is used to create database objects.
• INSERT adds new records.
• SELECT retrieves data.
• UPDATE modifies existing records.
• DELETE removes records.
SELECT Examples
• SELECT * FROM students; shows all columns.
• SELECT name, mark FROM students; shows selected columns.
• WHERE filters records.
• ORDER BY sorts records.
• LIMIT restricts number of results.
Joins
• INNER JOIN returns matching records from both tables.
• LEFT JOIN returns all rows from left table and matching rows from right table.
• Joins are used when data is split across multiple tables.
Aggregate Functions
• COUNT() counts rows.
• SUM() adds values.
• AVG() gives average.
• MAX() gives highest value.
• MIN() gives lowest value.
• GROUP BY groups similar records.
Original study notes - created for educational use Page 1