SQL - SPLessons

SQL Where Clause

Chapter 33

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Where Clause

SQL Where Clause

shape Description

SQL stands for Structured Query Language. The dialect initially created by IBM at mid 1970. It is utilized for dealing with the database. It is a non-procedural dialect. Client can compose SQL script to execute and SQL compiler consequently produces a method to get to database and convey the fancied output. SQL is a database coding, planned for the recuperation and organisation of data in social database.

To specify conditions in SQL command use SQL Where Clause. i.e., Select * from the table name will show all the rows from the table and SQL Where Clause will specify the condition for the result set in the table.

shape Syntax

The syntax for Where Clause is as follows:
Select * from <table_name> where <condition>;

table_name => Any accurate table.

condition => condition is a logic to get a specific record.

shape Examples

By viewing the below example, the concept of Where Clause can be easily understood.

sql> select * from employee;
+--------+-------+-------+
| emp_id | ename | salary|
+--------+-------+-------+
|   1001 | mike  | 12000 |
|   1002 | rambo | 13000 |
+--------+-------+-------+
2 rows in set (0.00 sec)

sql> select * from employee where ename='rambo';
+--------+-------+-------+
| emp_id | ename | salary|
+--------+-------+-------+
|   1002 | rambo | 13000 |
+--------+-------+-------+
1 row in set (0.00 sec)

sql> select * from employee where salary=12000;
+--------+-------+-------+
| emp_id | ename |salary |
+--------+-------+-------+
|   1001 | mike  | 12000 |
+--------+-------+-------+
1 row in set (0.00 sec)

The above example tells that, when SQL Where Clause operation is performed on a column name like rambo, then it automatically displays the entire details of rambo like emp_id and salary.And then in another query where clause is performed on column name like salary,then it automatically displays the entire details of that employee like emp_id,ename and salary.

Summary

shape Key Points

  • SQL Where Clause – Is used to specify condition in select statement.