Narayana Tutorial

Online Java Tutorial Blog

SQL WHERE


SQL WHERE Statement

In this tutorial post, we are going to discussing SQL WHERE statement in oracle data base. Oracle provides the option of using WHERE statement in an SQL query to apply a filter on the rows retrieved.

When a WHERE clause is added to the SQL query, then query executing as follows.

  • The Oracle engine compares each record in the table with the condition specified in the WHERE clause.
  • The Oracle engine displays only those records that satisfy the specified condition.

Consider we have EMPLOYEE demo table which is using for the executing WHERE command.

EMP_ID EMP_NAME EMP_DESIGNATION EMP_GENDER EMP_QUALIFICATION EMP_LOCATION
100 Narayanaswamy Sr.Software Engineer Male MCA Chennai
101 Kumar Quality Analyst Male B.Tech Chennai
102 Ramesh Database Administration Male B.Tech Chennai

Filtering Table Data

The ways of filtering table data are:

 

Selected columns and all columns

By using SELECT statement we can achieve above criteria. Click here to see the article.

 

Selected rows and all columns

By using WHERE statement we can achieve above criteria as follows.

Syntax:

SELECT * FROM <Table-Name> WHERE <Condition>;

Here <Condition> is always quantified as <Column-Name = Column-Value>

Query:

SELECT * FROM EMPLOYEE WHERE EMP_ID=100;

It will return all columns and selected rows result set data from the table as below.

EMP_ID EMP_NAME EMP_DESIGNATION EMP_GENDER EMP_QUALIFICATION EMP_LOCATION
100 Narayanaswamy Sr.Software Engineer Male MCA Chennai

 

Selected columns and selected columns

By using WHERE statement we can achieve above criteria as follows.

Syntax:

SELECT <Column-Name 1>,<Column-Name 2> FROM <Table-Name> WHERE <Condition>;

Here <Condition> is always quantified as <Column-Name = Column-Value>

Query:

SELECT EMP_ID,EMP_NAME FROM EMPLOYEE WHERE EMP_ID=100;

It will return selected columns EMP_ID, EMP_NAME and selected rows where EMP_ID=100, result set data from the table as below.

EMP_ID EMP_NAME
100 Narayanaswamy
Narayanaswamy

Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development.

I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

The Author

Narayanaswamy

Narayanaswamy

Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply

Narayana Tutorial © 2016 Frontier Theme
Show Button
Hide Button