Back to Top

Saturday, 23 February 2013

SQL: WHERE Command

In SQL,when ever you want to SELECT some data, or UPDATE or DELETE some information from a Table, you needs to provide some condition, on basis of which operation will be performed. It's not necessary to SELECT, UPDATE or DELETE all data from a table or view. So, condition is necessary to filter the data when performing an operation on database. The basic structure of of WHERE conditions is :

  Syntax: SELECT [column_name] FROM [table_name] WHERE [condition]

Example:

Again, we will see the same table
Employee Details ( employee_details), which contains 
Employee ID ( emp_id), 

Employee Name (emp_name), 
Employee Address (emp_address) and
Employee Role: (emp_role).

Table:  employee_details 






Now, from this table, if a situation ariser, where we have to just select the information of the developers, the we have to set some condition on our SELECT query, so that we can get the details of the employees with 'emp_role' 'Developer' . Then the Query will be

SELECT * FROM employee_details WHERE emp_role = 'Developer';

Result:





In this way we can filter our data output.

0 Responses to “ SQL: WHERE Command ”

Post a Comment

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs