Query, join, and manage relational data — written by Aivasu Tech Institute's mentors. Free to read, structured to actually help you learn.
SQL notes by Aivasu Tech Institute cover 102 topics — from sql home to joining multiple tables in sql — each explained with short definitions, syntax and runnable code examples. They are 100% free, need no signup, and work as quick revision for college exams, SQL interviews and Aivasu Tech Institute's mentor-led SQL course in Pitampura, Delhi.
SQL Tutorial chapters
SQL Database chapters
Databases, tables, data types and the core DDL/DML commands.
SELECT, filtering, sorting and combining result sets with set operators.
INNER, LEFT, RIGHT, FULL, CROSS and SELF joins explained with sample tables.
No notes found. Try a different search term, or browse all SQL notes.
SQL is the universal language of databases, and every analyst, backend developer and data engineer uses it daily. This free track takes you from writing your first query to joins, views and security best practices.
Structured Query Language lets you store, search and manage data held in relational databases. Start here to understand what SQL is, why it powers almost every serious application, and how you will use it in real jobs.
SQL reads like simple English, but its syntax rules decide whether a query runs or crashes. Master the basic structure of statements, keywords and semicolons before moving to complex queries.
SELECT is the first command every SQL learner writes and the one professionals use hundreds of times a day. It fetches exactly the columns you need from a table without disturbing the underlying data.
Real-world tables are full of repeated values, and SELECT DISTINCT is the tool that removes them in one line. Data analysts rely on it constantly to find unique customers, cities or categories.
The WHERE clause turns a dump of rows into a precise answer by filtering records against conditions. Almost every business question you answer with SQL starts with a good WHERE clause.
Sorted output is what makes reports readable, and ORDER BY gives you full control over it. Learn to arrange rows by one or more columns in ascending or descending order.
The AND operator lets you stack several filter conditions into one query, so you can ask questions like rows matching this AND that. It is the backbone of precise data filtering.
OR widens your query to match rows that satisfy any of several conditions. Knowing when to combine OR with AND, and how to group them, prevents silently wrong results.
NOT inverts a condition and is perfect for excluding records — everything except a category, a date range or a status. It reads naturally and keeps complex filters short.
Adding data is just as important as reading it, and INSERT INTO is how new rows enter a table. You will use it when building apps, loading files and setting up test data.
NULL means the value is unknown or missing, and it behaves differently from zero or an empty string. Handling NULL correctly separates careful developers from bug-prone queries.
The UPDATE statement changes existing rows in place, which is why every developer treats it with care. Pairing it with WHERE is the difference between fixing one record and ruining a whole table.
DELETE removes rows permanently, so understanding it properly protects real business data. Learn how to target the right records and why forgetting WHERE is the classic SQL disaster.
Working with big tables often means you only want the first few rows, and SELECT TOP (or LIMIT) delivers exactly that. It is handy for sampling data and building leaderboards.
Aggregate functions compress thousands of rows into a single answer — totals, averages, counts and more. They are the heart of every dashboard and summary report.
MIN() finds the smallest value in a column, from the cheapest product to the earliest date. It is one of the first tools you reach for when exploring a new dataset.
MAX() returns the largest value in a column, like the highest salary or the most recent order. Combined with grouping, it answers best-of questions in one query.
COUNT() tells you how many rows match your conditions, and it is often the first number a stakeholder asks for. Learn its variants, including counting distinct values.
SUM() adds up a numeric column — revenue, hours, quantities — turning raw rows into business totals. It powers invoices, budgets and every sales report.
AVG() computes the average of a numeric column, from order values to delivery times. Watch how it handles NULLs, because that detail changes your answer.
LIKE searches for patterns inside text using wildcards, so you can find names, emails or product codes without exact matches. It is the workhorse of fuzzy text search in SQL.
Wildcards are the pattern symbols that make LIKE powerful — % matches any characters, _ matches one. Mastering them turns vague search terms into reliable filters.
IN lets you match a column against a list of values in one clean clause instead of chaining many ORs. It is the natural way to query for a set of known items.
BETWEEN checks whether a value falls inside a range, making date and price filters short and readable. Remember that its bounds are inclusive, which trips up beginners.
Aliases give tables and columns temporary short names, keeping complex queries readable. They are also what puts clean column headings on your exported reports.
Joins combine rows from multiple tables, which is where SQL starts earning its keep. Nearly every real business query pulls data from at least two tables using joins.
INNER JOIN returns only the rows that match in both tables — the standard way to link orders to customers or employees to departments. It is the join you will use most often.
LEFT JOIN keeps every row from the first table even when no match exists in the second, filling gaps with NULLs. It is perfect for finding customers with no orders yet.
RIGHT JOIN mirrors LEFT JOIN by keeping all rows from the second table instead. It is used less often, but knowing it makes join logic complete.
FULL JOIN returns rows from both tables, matched where possible and NULL-padded elsewhere. It is the tool for comparing two datasets side by side.
A self join links a table to itself, which sounds odd until you need to compare employees with their managers or find pairs of related products. It unlocks hierarchical queries.
UNION stacks the results of two queries into one list while removing duplicates. It is how you combine similar datasets from different tables or reports.
UNION ALL also stacks result sets but keeps every row, duplicates included. Use it when you need speed and know duplicates are impossible or acceptable.
GROUP BY collapses rows that share a value so aggregates run per group — sales by city, orders by month. It is the engine behind every grouped report.
HAVING filters groups the way WHERE filters rows, so you can ask for categories with sales above a threshold. It is the step beginners usually miss.
EXISTS checks whether a subquery returns any rows, which is often faster than joining when you only care about existence. It reads naturally in business questions.
ANY compares a value against every result of a subquery and matches if at least one comparison succeeds. It gives you subquery power in a single operator.
ALL matches only when a comparison holds against every row returned by a subquery — for example, salaries greater than all values in a list. It is the strict cousin of ANY.
SELECT INTO copies query results into a brand-new table in one step. It is a quick way to build backups and snapshots during development.
INSERT INTO SELECT moves data between tables by combining an insert with a query. It powers bulk copies, table merges and archive jobs.
CASE works like if-else logic inside a query, letting you map codes to labels or bucket values into ranges. It keeps transformations inside the database instead of the app.
NULL-handling functions like COALESCE and IFNULL swap missing values for sensible defaults. Reports that show blanks today become clean and useful with these.
Stored procedures package a whole sequence of SQL into a reusable, callable routine. They centralise business logic and are a must-know for database developer roles.
Comments document your queries so teammates — and future you — understand the intent. Good commenting is a professional habit interviewers notice.
SQL operators — arithmetic, comparison, logical and bitwise — let you calculate and decide inside queries. A firm grip on operator precedence prevents subtle wrong results.
CREATE DATABASE initialises the container that will hold all of a project's tables. It is the first step in setting up any new system.
DROP DATABASE permanently deletes a database and everything inside it. Learn when and why you would use it, and why backups come first.
Backups are what stand between you and total data loss, and every serious setup automates them. Learn the standard ways to back up and restore a database.
CREATE TABLE defines the structure that stores your data — columns, types and rules. A well-designed table makes every later query simpler and faster.
DROP TABLE removes a table and all its rows permanently. Understanding the difference between dropping, truncating and deleting saves real accidents.
Requirements change, and ALTER TABLE lets you add, modify or remove columns without rebuilding the table. It is how live databases evolve safely.
Constraints are the rules you set on columns — uniqueness, non-null, valid ranges — so bad data never enters the system. They are your first line of data-quality defence.
NOT NULL guarantees a column always holds a value, blocking the missing data that breaks reports and logic. It belongs on every field that is truly required.
The UNIQUE constraint prevents duplicate values in a column, such as two users with the same email. It keeps data clean without extra application code.
A primary key uniquely identifies every row in a table, and every well-designed table has one. It anchors relationships and makes lookups fast and reliable.
Foreign keys link rows across tables and enforce referential integrity, so you cannot reference a customer that does not exist. They are the glue of relational design.
CHECK validates values against a condition before they are stored — ages above zero, statuses from a fixed list. It catches bad data at the database, not just in the app.
DEFAULT supplies a value automatically when none is provided, keeping inserts short and consistent. It quietly powers fields like timestamps and status flags.
Indexes dramatically speed up searches on large tables, much like a book's index. Learn when to add them — and why too many slow down writes.
AUTO INCREMENT lets the database assign the next number to each new row, giving you effortless unique IDs. It is the standard primary-key strategy.
Dates have their own data types and functions in SQL, and real reporting depends on handling them correctly. Learn to store, filter and format date values properly.
Views are saved, reusable queries that behave like tables while keeping the real data untouched. They simplify reporting and hide complex joins from end users.
SQL injection is a top web vulnerability where attackers manipulate queries through user input. Understanding it is non-negotiable for anyone building database-driven apps.
Parameterised queries separate data from SQL code, neutralising injection attacks at the source. This is the secure way every modern application talks to a database.
Prepared statements compile a query once and reuse it with different values, combining safety and performance. They are the recommended pattern for all dynamic queries.
A database has to live somewhere, and hosting options range from local servers to managed cloud services. Learn how production databases are deployed, secured and backed up.
What SQL actually is, what it does, and why it matters for analysts and developers.
What a relational database is, and how MySQL, PostgreSQL, SQL Server and others compare.
How relational (SQL) and non-relational (NoSQL) databases differ, and when to use each.
The major SQL data type categories and how they differ across MySQL, PostgreSQL and SQL Server.
How to create a new SQL database, with syntax and dialect notes.
How to define a new table with columns, data types and constraints.
How to add, modify, rename and drop columns on an existing table.
How to permanently delete a table, and when to use it instead of TRUNCATE or DELETE.
How TRUNCATE instantly clears a table, and exactly how it differs from DELETE.
How to add new rows to a table — single row, multiple rows, and INSERT...SELECT.
How to modify existing rows safely — and why the WHERE clause is critical.
How to remove specific rows from a table, and how DELETE compares to TRUNCATE and DROP.
The most-used SQL statement — retrieving columns from a table.
How to remove duplicate rows from a result set using DISTINCT.
How to filter rows with WHERE, and the comparison operators available.
Combining multiple conditions in WHERE, and why parentheses matter.
Reversing a condition with NOT, including its behavior with NULL values.
Matching a value against a list, and using IN with a subquery.
Filtering values within an inclusive range, including the datetime gotcha.
Pattern matching with % and _ wildcards for partial text search.
Testing for missing values correctly — why = NULL never works.
Sorting query results, including multi-column sorts.
Restricting row count for top-N results and pagination.
Renaming columns and tables for readability with AS.
Adding if/else logic to a query, and the CASE + SUM pivot pattern.
An overview of all six SQL join types, with a shared reference dataset used across this section.
Returning only rows that match in both tables — syntax, example, and common mistakes.
Keeping every row from the left table, and the LEFT JOIN + IS NULL pattern for finding unmatched rows.
Keeping every row from the right table — the mirror image of LEFT JOIN.
Keeping every row from both tables, and how to simulate it in MySQL.
Producing every combination of two tables — the Cartesian product.
Joining a table to itself for hierarchical data like employees and managers.
The core difference, and how to decide which join type a report actually needs.
Why they're mirror images of each other, and why LEFT JOIN is the common convention.
Chaining three or more joins together to build real, multi-table reports.
Join Aivasu Tech Institute's SQL course — live mentorship, hands-on projects, and 100% placement support in Delhi NCR.
Enroll Now — Free Demo Available✳ Common questions
What students search before reading SQL notes.