SQL AND Operator - The Coding Shala

Home >> Learn SQL >> SQL AND Operator

SQL AND Operator

The SQL 'AND' operator is used to filter out the records based on the one or more columns. The WHERE clause can be combined with AND operator. The SQL AND Operator display records if all the conditions that are separated by 'AND' are true.
SQL AND Operator - The Coding Shala

SQL AND Operator syntax

The basic SQL AND operator syntax is as follows - 

SELECT column1, column2, ...  
 FROM table_name  
 WHERE condition1 AND condition2 AND condition3 ...;  

SQL AND Operator Examples 

The following 'emp' table will be used for the examples - 

 Id     Name     Age     Address     Salary  
 1     Akshay     22     Pune        40000  
 2     Mohit      21     Delhi       42000  
 3     Akash      21     Delhi       45000  
 4     Nikhil     24     Mumbai      50000  
 5     Smith      24     Pune        50000  
 6     Akshay     22     Pune        50000  
7 Nikhil 24 Mumbai 43000


The following query will return records from emp where Age is 22 And Address in Pune - 


SQL >> select * from emp  
        where Age = 22 AND Address = 'Pune';  

 Output >>   
 Id     Name     Age     Address     Salary  
 1     Akshay     22     Pune        40000  
 6     Akshay     22     Pune        50000


Other Posts You May Like
Prev<< SQL Union Clause                                                                        NEXT >>SQL OR Operator
Please leave a comment below if you like this post or found some error, it will help me to improve my content.

Comments

Popular Posts from this Blog

Java Program to Convert Binary to Decimal - The Coding Shala

Shell Script to Create a Simple Calculator - The Coding Shala

N-th Tribonacci Number Solution - The Coding Shala

LeetCode - Shuffle the Array Solution - The Coding Shala

Java Program to Find GCD or HCF of Two Numbers - The Coding Shala