SQL Where

In SQL, the WHERE clause is used to specify conditions for filtering rows in a query result. It allows you to extract only the rows that meet certain criteria. The general syntax of the WHERE clause is as follows:

sql
SELECT column1, column2, ...
FROM table
WHERE condition;

Here, column1, column2, and so on represent the columns you want to retrieve from the table, and table represents the name of the table you are querying. The condition is the expression that specifies the criteria for filtering rows.

The condition can be constructed using various operators, such as:

  • Comparison operators (e.g., =, <>, >, <, >=, <=) to compare values.
  • Logical operators (AND, OR, NOT) to combine multiple conditions.
  • Pattern matching operators (LIKE, NOT LIKE) to match patterns in string values.
  • NULL-related operators (IS NULL, IS NOT NULL) to check for null values.

Here are a few examples to illustrate the usage of the WHERE clause:

  1. Retrieve all rows from the “Customers” table where the “Country” column is set to ‘USA’:
sql
SELECT *
FROM Customers
WHERE Country = 'USA';
  1. Retrieve rows from the “Orders” table where the “TotalAmount” column is greater than or equal to 1000 and the “Status” column is not ‘Cancelled’:
sql
SELECT *
FROM Orders
WHERE TotalAmount >= 1000 AND Status <> 'Cancelled';
  1. Retrieve rows from the “Employees” table where the “LastName” column starts with ‘Smi’ and the “Age” column is less than 30:
sql
SELECT *
FROM Employees
WHERE LastName LIKE 'Smi%' AND Age < 30;

These are just a few examples, and you can construct more complex conditions using different operators as per your requirements.

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

_

_

_