SQL WHERE Statement

SQL WHERE Statement:

(1) “WHERE” statement use for filtering records in table from database.

(2) Syntax of “WHERE” statement is:

SELECT DISTINCT column1, column2, …
FROM table_name
WHERE condition;

(3) Lets take an example to select only values from the “Country_Region Code” column in the “Vendor table” according to the condition.

(4) Select database in SQL server and click on “New Query” button as shown.

select database for selecting records in sql

(5) After that new query editor open as shown.

new query editor open in sql

(6) After doing the above steps, write query in the editor, as shown.

SQL WHERE Statement Example

Source Code:

–// Without “WHERE” condition in “Country_Region Code” column in Vendor table
Select [No_],[Country_Region Code] from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]
SELECT..FROM WHERE syntax
–// Without “WHERE” condition in “Country_Region Code” column in Vendor table

–// With “WHERE” condition in “Country_Region Code” column in Vendor table
Select [No_],[Country_Region Code] from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]
where [Country_Region Code] = ‘AT’
–// With “WHERE” condition in “Country_Region Code” column in Vendor table

(7) After writing the query, then execute the query (Shortcut keys is F5) as shown.

execute the query for where statement in sql

(8) After executing the two queries in the same editor, SQL gives two results. Note: Recommended write and execute query one by one for reporting.


How To Import License File In Business Central D365 On-premises
How to Export-NAV ServerLicenseInformation From Business Central D365 On-premises
How to Switch Companies in Dynamics 365 Business Central
How to Create New Companies in Dynamics 365 Business Central
Creating New Companies in Business Central– Microsoft Docs

Leave a Reply