Use of AND operator in SQL

Use of AND operator in SQL:

(1) “AND” operator is used where two conditions are executed. It shows records when all conditions are true.

(2) Syntax of “AND” statement is:

SELECT DISTINCT column1, column2, …
FROM table_name
WHERE Cond1 AND Cond2 AND CondN;

(3) Let’s take an example to get records according to the “No.” & “Address” columns are equal to the assigned values as shown.

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

Select the database in SQL server and click on the New Query

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

new query editor open in sql

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

and operator query in sql

Source Code:

–// Without “AND” operator in Vendor table
Select [No_],[Name],[Address] from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]
–// Without “AND” operator in Vendor table

–// With “AND” operator in Vendor table
Select [No_],[Name],[Address]from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972]
where [No_] = ‘01254796’ AND Address = ‘222 Reagan Drive’
–// With “AND” operator in Vendor table

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

execute and operator sql query

(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.


SQL ORDER BY Statement
SQL WHERE Statement
SQL SELECT DISTINCT Statement
How to add or show new field in existing Page in D365 BC
Page Extension Object– Microsoft Docs

Leave a Reply