SQL And Or Keywords, SQL Tutorial, Global Guide Line Technology.
Bookmark Bookmark: SQL And Or Keywords, SQL Tutorial Forum | Blog |


Basic SQL Guide.           
SQL Introduction.               
 What is Table?                  
 SQL Create Table.            
 SQL Insert Statement.      
 SQL Select Keyword.        
 SQL Order by clause.        
 SQL Count Statement.      
 SQL Group By Clause.      
 SQL Having Clause.          
 SQL Alias Tables.             
 SQL Join Tables.              
 SQL Outer Join.               
 SQL Update Statement.   
 SQL Delete Statement.    
 SQL Distinct Keyword.      
 SQL Where Keyword.       
 SQL And Or Keyword.
 SQL In Keyword.              
 SQL Between Keyword.   
 SQL Like Keyword.          
 SQL Functions.                
 SQL Concatenate.           
 SQL Substrings.               
 SQL Trim Function.         
 SQL Constraints.              
 SQL Primary Key.            
 SQL Foreign Key.            
 SQL Create Views.           
 SQL Create Index.           
 SQL Alter Table.             
 SQL Drop Table.             
 SQL Truncate Table.      
 SQL Summary.                

SQL Tutorial >> SQL And Or Keywords.

     Back             Next     

In the previous section of SQL Tutorial, we have seen that the SQL WHERE keyword can be used to conditionally select data from a table in database. This condition can be a simple condition like the one presented in the previous section of this SQL Tutorial, or it can be a compound condition. Compound conditions are made up of multiple simple SQL conditions connected by SQL AND or OR Keywords. There is no limit to the number of simple conditions that can be present in a single SQL statement.

The syntax for a compound condition of SQL AND OR Keywords are as follows:

Syntax for SQL AND OR Keywords

SELECT "column_name"
FROM "table_name"
WHERE "simple condition"
{[AND|OR] "simple condition"}+

The {}+ means that the expression inside the bracket will occur one or more times. Note that SQL AND and OR keywords can be used interchangeably. In addition, we may use the parenthesis sign () to indicate the order of the condition.

For example, we may wish to select all Employess record who have Salary greater than 1000$ or all Employees who have Salary less then equals 1200$ in table Employees_Salary,
  Table of Employees_Salary

FirstName Month Salary
Austin January 1100$
Creston January 1000$
Kate January 1200$
Angela January 1000$
Bobbi January 1250$
Cute January 1300$

Example of SQL AND OR Keywords

SELECT FirstName, Month, Salary
FROM Employees_Salary
WHERE Salary > 1000
AND Salary <= 1200

Result or SQL AND OR Keywords Example

FirstName Month Salary
Austin January 1100$
Kate January 1200$

Explanation of above query
Here we can see that only the Austin and Kate are the only two employees who are having Salary more then 1000$ and less then equals 1200$. Other records are not meeting the criteria of our requirements.

     Back             Next     

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2019 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 133 visitors are online now