Skip to content

πŸ—‚οΈA collection of essential SQL queries covering SELECT πŸ“, INSERT βž•, DELETE ❌, UPDATE πŸ”„, and JOIN πŸ”— operations for database management and learning.

License

Notifications You must be signed in to change notification settings

Hifza-Khalid/SQL-Queries-Collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SQL Queries Collection

License GitHub stars ⭐ GitHub forks 🍴 GitHub issues 🐞

Welcome to the SQL Queries Collection repository! πŸŽ‰ This repository contains a collection of SQL queries for a variety of common operations and tasks, such as SELECT, INSERT, UPDATE, DELETE, and JOIN operations, which are fundamental to working with SQL databases. The goal of this project is to provide practical SQL code examples for easy learning and reference. πŸš€


Table of Contents

πŸ”½ Click to expand Table of Contents

Project Overview

This project is designed to help developers and learners with SQL queries. It contains organized SQL query files that can be used in your projects or as learning examples. Whether you're just starting with SQL or you need a quick reference, you'll find useful query examples here. The repository is open for contribution, so feel free to add your own queries or improvements. πŸ“š


Queries Collection

πŸ“Š SELECT Queries

This file contains examples of various SELECT statements that are fundamental for retrieving data from a database. πŸ“

  • Basic SELECT: Retrieve all records from a table.
  • WHERE Clause: Filter data based on conditions.
  • AND/OR Conditions: Combine multiple conditions.
  • LIKE Pattern Matching: Search for records with specific patterns.
  • ORDER BY: Sort the results.
  • DISTINCT: Retrieve unique values.
  • JOIN Queries: Combine data from multiple tables.

Example:

SELECT * FROM employees;

You can find more details in the SELECT-Queries.sql file. πŸ“„

πŸ”— JOIN Queries

This file demonstrates different types of JOIN operations for combining data from multiple tables. 🌐

  • INNER JOIN: Returns rows when there is a match in both tables.
  • LEFT JOIN: Returns all rows from the left table and matched rows from the right table.
  • RIGHT JOIN: Returns all rows from the right table and matched rows from the left table.
  • FULL OUTER JOIN: Returns all rows when there is a match in one of the tables.
  • SELF JOIN: Join a table with itself.

Example:

SELECT e.first_name, e.last_name, d.department_name
FROM employees e
INNER JOIN departments d ON e.department_id = d.department_id;

For more details, refer to the JOIN-Queries.sql file. πŸ“‘

βž• INSERT Queries

This file covers examples of INSERT queries for adding data into a table. ✨

  • Single INSERT: Add a single record to a table.
  • Multiple INSERT: Add multiple records at once.
  • INSERT from SELECT: Insert data from another table.

Example:

INSERT INTO employees (first_name, last_name, department, salary)
VALUES ('John', 'Doe', 'IT', 60000);

For more information, refer to the INSERT-Queries.sql file. πŸ“

✏️ UPDATE Queries

This file demonstrates the use of UPDATE queries to modify data in an existing table. πŸ”„

  • Basic UPDATE: Update a single record.
  • Multiple Record UPDATE: Modify data for multiple records.
  • UPDATE with JOIN: Modify data based on a JOIN condition.
  • Conditional UPDATE: Update data conditionally using CASE.

Example:

UPDATE employees
SET salary = 65000
WHERE first_name = 'John' AND last_name = 'Doe';

Check the UPDATE-Queries.sql file for further examples. πŸ”„

πŸ—‘οΈ DELETE Queries

This file includes various DELETE queries for removing data from a table. πŸ—ƒοΈ

  • Basic DELETE: Remove a specific record.
  • DELETE Multiple Records: Delete records based on a condition.
  • DELETE with JOIN: Delete records based on a JOIN condition.
  • TRUNCATE: Remove all records from a table.

Example:

DELETE FROM employees
WHERE first_name = 'John' AND last_name = 'Doe';

More examples can be found in the DELETE-Queries.sql file. πŸ—ƒοΈ


Contributing

We welcome contributions from the community! 🀝 If you'd like to contribute, please follow these steps:

  1. Fork the repository 🍴.
  2. Create a new branch (git checkout -b feature-name) 🌱.
  3. Make your changes ✨.
  4. Commit your changes (git commit -am 'Add new query') πŸ“.
  5. Push to your branch (git push origin feature-name) πŸš€.
  6. Open a pull request πŸ”„.

Please ensure that your contributions are in the form of SQL code examples with proper comments explaining the query logic. πŸ’¬


License

This project is licensed under the MIT License - see the LICENSE file for details. πŸ“œ


Links

Feel free to use, modify, and contribute to this collection of SQL queries. Happy querying! πŸŽ‰

About

πŸ—‚οΈA collection of essential SQL queries covering SELECT πŸ“, INSERT βž•, DELETE ❌, UPDATE πŸ”„, and JOIN πŸ”— operations for database management and learning.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published