SQL And, Or, Not

SQL And, Or, Not

In SQL, “AND,” “OR,” and “NOT” are logical operators used to combine or negate conditions in a query’s WHERE clause. These operators allow you to create more complex and specific conditions for filtering data from database tables. Here’s a brief explanation of each operator:

  1. AND: The AND operator is used to specify that all conditions separated by it must be true for a row to be included in the result set. It narrows down the result by making the query more restrictive. For example:sql
SELECT * FROM customers WHERE age >= 18 AND country = 'USA';

This query selects all customers who are at least 18 years old and reside in the USA.

OR: The OR operator is used to specify that at least one of the conditions separated by it must be true for a row to be included in the result set. It broadens the result by making the query less restrictive. For example:

sql
SELECT * FROM products WHERE category = 'Electronics' OR price < 1000;

This query selects all products that belong to the Electronics category or have a price below 1000.

NOT: The NOT operator is used to negate a condition, excluding rows that meet the specified condition. It reverses the logical meaning of the condition. For example:

sql
  1. SELECT * FROM employees WHERE NOT department = 'HR'; This query selects all employees who do not work in the HR department.

These logical operators can be combined to create more complex conditions using parentheses to establish the desired order of evaluation.

Leave a Reply

Your email address will not be published. Required fields are marked *

GLOTRU Footer
Popular Features
Popular Services/

Website Development & Design

App Development & Design

Graphic Design

Digital Marketing

SEO (Search Engine Optimization)

SMM (Social Media Marketing)

Cyber Security

Company

GLOTRU Founder & CEO : __Azam

Registared : Trade,MSME,etc

Board of Director

Team

About Us

Contact Us

Privacy Policy

Return & Refund Policy

Abuse Policy

Copyright Policy

Cookie Policy

Terms & Conditions

Universal Terms of Service

Disclaimer

Legal

Sponsorships

Investor

Press Releases

Our Investments

Brands

Newsroom

Business

...

_

Digital Millennium Copyright Act
DMCA.com Protection Status

_

Content similarity detection
Protected by Copyscape

_

***ANTI-PIRACY WARNING***

...................................................................................

Follow Us :

...................................................................................

SECURE SERVER : [Legal] [Privacy Policy] [Universal Terms of Service] [Do not sell my personal information]

SITE HOSTED : GLOTRU SECURE SERVER Asian Data Centre [You can host your site][Click Here]

SSL : Server Type : [Cloudflare] Certificate Issued By : [Let's Encrypt] Signature Algorithm : [ECDSA with SHA-384]

SITE BUILD SOFTWARE : Content Management System (CMS) Softwere

_

_

_