SQL Tutorial
What is SQL SQL SELECT SQL SELECT DISTINCT SQL WHERE SQL INSERT SQL UPDATE SQL DELETE SQL AND, OR & NOT Clause SQL ORDER BY SQL LIKE Clause SQL IN Operator SQL BETWEEN Operator SQL MAX() and MIN() SQL COUNTSQL JOIN
SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOINSQL AND, OR & NOT Clause
The SQL AND, NOT & OR operators are used to combine multiple conditions to filter data in an SQL statement. These there operators are called as the conjunctive operators.
Example Database:
This is customers table.
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
3 | Siddarth | Noida |
4 | Vikas | Noida |
AND Operator
The AND operator displays a record if all the conditions separated by AND are TRUE.
Syntax:
SELECT * FROM table_name WHERE condition1 AND condition2;
Example:
SELECT * FROM customers WHERE id = 1 AND location = 'Delhi';
Result:
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
OR Operator
The OR operator is used to combine multiple conditions in an SQL statement's WHERE clause. It means OR operator displays a record if any of the conditions separated by OR is TRUE.
Syntax:
SELECT * FROM table_name WHERE condition1 OR condition2;
Example:
SELECT * FROM customers WHERE id = 1 AND location = 'Noida';
Result:
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
3 | Siddarth | Noida |
4 | Vikas | Noida |
NOT Operator
The NOT operator displays a record if the condition(s) is NOT TRUE.
Syntax:
SELECT * FROM table_name WHERE NOT condition;
Example:
SELECT * FROM customers WHERE NOT location='Noida';
Result:
id | name | Location |
---|---|---|
1 | Kailash | Delhi |
2 | Amit | Haryana |
SEARCH POST HERE
Support Us
Subscribe My YouTube Channel
Join Our Telegram Channel & Support Eachother
CATEGORIES
INTERVIEW QUESTIONS
POPULAR POSTS
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date