0% found this document useful (0 votes)
2 views3 pages

Complete SQL Tutorial Guide

The document is a comprehensive SQL tutorial covering key concepts such as SELECT statements, WHERE clauses, ORDER BY, aggregate functions, joins, subqueries, and data modification commands. It also discusses creating and managing tables, constraints, views, transactions, and stored procedures. Additionally, it suggests practice projects for applying SQL skills in real-world scenarios.

Uploaded by

kannanarun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Complete SQL Tutorial Guide

The document is a comprehensive SQL tutorial covering key concepts such as SELECT statements, WHERE clauses, ORDER BY, aggregate functions, joins, subqueries, and data modification commands. It also discusses creating and managing tables, constraints, views, transactions, and stored procedures. Additionally, it suggests practice projects for applying SQL skills in real-world scenarios.

Uploaded by

kannanarun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Complete SQL Tutorial Guide

SELECT Statements
SELECT retrieves data from tables.
SELECT * FROM employees;
SELECT name,salary FROM employees;

WHERE Clause
WHERE filters rows based on conditions.
SELECT * FROM employees WHERE salary > 50000;

ORDER BY and LIMIT


ORDER BY sorts results. LIMIT restricts rows returned.
SELECT * FROM employees ORDER BY salary DESC;
SELECT * FROM employees LIMIT 5;

Aggregate Functions
COUNT, SUM, AVG, MIN and MAX summarize data.
SELECT COUNT(*) FROM employees;
SELECT AVG(salary) FROM employees;

GROUP BY and HAVING


GROUP BY creates groups. HAVING filters grouped results.
SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*)>1;

Joins
Combine data from multiple tables.
SELECT [Link],d.department_name FROM employees e INNER JOIN departments d ON e.department_id=[Link]

Subqueries
A query inside another query.
SELECT * FROM employees WHERE salary>(SELECT AVG(salary) FROM employees);

INSERT UPDATE DELETE


Modify data in tables.
INSERT INTO employees VALUES(1,'Arun',50000);
UPDATE employees SET salary=55000 WHERE id=1;
DELETE FROM employees WHERE id=1;

CREATE ALTER DROP


Create, modify and remove tables.
CREATE TABLE employees(id INT PRIMARY KEY,name VARCHAR(100));

Constraints
Rules that protect data integrity: PRIMARY KEY, FOREIGN KEY, UNIQUE, NOT NULL.
email VARCHAR(100) UNIQUE
Views and Indexes
Views simplify queries. Indexes improve performance.
CREATE VIEW high_salary AS SELECT * FROM employees WHERE salary>50000;

Transactions
Use COMMIT and ROLLBACK to ensure safe data changes.
START TRANSACTION;
COMMIT;
ROLLBACK;

Stored Procedures and Triggers


Automate repetitive database tasks.
CALL GetEmployees();

Practice Projects
Build Inventory, Sales, Student Management, and ERP systems using SQL.
products, sales, customers, suppliers, stock
Next Steps
Practice every query in MySQL Workbench and build a mini ERP database.

You might also like