SQL Operator
Here in this section we have added a cheat sheet for SQL Operators. So, explore and learn how to use AND, OR, NOT and others oprtators.
24. AND: Combines Multiple Conditions In A WHERE Clause
SELECT * FROM employees
WHERE department = 'IT' AND salary > 60000;
This query will retrieve employees who work in the IT department and have a salary greater than 60000.
25. OR: Specifies Multiple Conditions Where Any One Of Them Should Be True
SELECT * FROM employees
WHERE department = 'HR' OR department = 'Finance';
This query will retrieve employees who work in either the HR or Finance department.
26. NOT: Negates A Condition
SELECT * FROM employees
WHERE NOT department = 'IT';
This query will retrieve employees who do not work in the IT department.
27. LIKE: Searches For A Specified Pattern In A Column
SELECT * FROM employees
WHERE first_name LIKE 'J%';
This query will retrieve employees whose first name starts with ‘J’.
28. IN: Checks If A Value Matches Any Value In
SELECT * FROM employees
WHERE department IN ('HR', 'Finance');
This query will retrieve employees who work in the HR or Finance departments.
29. BETWEEN: Selects Values Within a Specified Range
SELECT * FROM employees
WHERE salary BETWEEN 50000 AND 60000;
This query will retrieve employees whose salary is between 50000 and 60000.
30. IS NULL: Checks if a Value is NULL
SELECT * FROM employees
WHERE department IS NULL;
This query will retrieve employees where the department is not assigned (NULL).
31. ORDER BY: Sorts the Result Set in Ascending or Descending Order
SELECT * FROM employees
ORDER BY salary DESC;
This query will retrieve all employees sorted by salary in descending order.
32. GROUP BY: Groups Rows that have the Same Values into Summary Rows
SELECT department, COUNT(*) AS employee_count
FROM employees
GROUP BY department;
This query will group employees by department and count the number of employees in each department.
SQL Cheat Sheet
In this article, we will explore the ultimate SQL cheat sheet with the PDF, covering a wide range of SQL commands, Joins in SQL, CRUD Operations, SQL Trigger, SQL Transactions, and advanced topics to help master SQL effectively.
SQL (Structured Query Language) is a Query language used for managing and manipulating relational databases databases. It allows users to interact with databases. SQL allows users to perform various tasks such as querying data, updating data, inserting new records, deleting records, creating and modifying database schemas, and managing permissions.
Table of Content
- Create a Database in SQL
- Creating Data in SQL
- Reading/Querying Data in SQL
- Updating/Manipulating Data in SQL
- Deleting Data in SQL
- Filtering Data in SQL
- SQL Operator
- Aggregation Data in SQL
- Constraints in SQL
- Joins in SQL
- SQL Functions
- Subqueries in SQL
- Views in SQL
- Indexes in SQL
- Transactions in SQL
- Advanced Mixed Data in SQL
- SQL Cheat Sheet PDF
Contact Us