This repository contains SQL queries organized by topic.
Each file focuses on a specific SQL concept, making it easy to study and practice.
Topics
Common Table Expression.sqlbasic_functions.sql– Basic SQL functionsgroup by and having.sql– Using GROUP BY with HAVING clausejoins.sql– Different types of joinsself join.sql– Self join examplessubquery.sql– Subquery usageunion.sql– Combining results with UNIONwindow functions.sql– Window functions examplesaddress_foreign key.sql– Foreign key constraintscase statement.sql– CASE statementsindex.sql– Index creation and usagerollback.sqlstored procedure.sql– Stored procedurestriggers.sql– Database triggersview.sql– Creating and using views
-- Example from basic_functions.sql
SELECT UPPER(name), LENGTH(name) FROM users;
-- Example from union.sql
SELECT name FROM table1
UNION
SELECT name FROM table2;
-- Example from rollback.sql
SET AUTOCOMMIT= 0;
COMMIT;
UPDATE;
ROLLBACK;
SET AUTOCOMMIT= 1; (BY DEFAULT IN MYSQL)