We can select a particular row using the WHERE clause statement. We can also check any condition using WHERE clause or keyword. Where condition comes handy when we come across a big table having huge volume of data but we might want to see only small number of rows satisfying a condition.
The select where syntax is
SELECT what_to_select FROM tbl_name WHERE conditions_to_satisfy;
Here the conditions_to_satisfy specifies one or more conditions that rows must satisfy to qualify for retrieval.
Let's see an example query for retrieving a single student data using the WHERE clause.
mysql> select * from student where name = 'jack';
+--------+------+-------+-----------------+---------+
| studid | name | marks | address | phone |
+--------+------+-------+-----------------+---------+
| 4 | jack | 82 | victoria street | 2436821 |
+--------+------+-------+-----------------+---------+
1 row in set (0.00 sec)
Here in the above example query we have retrieved a single student details. Suppose if we want to retrieve the student's details who have secured more than 90 marks, we can use the below query.
mysql> select * from student where marks > 90;
+--------+-------+-------+------------------+---------+
| studid | name | marks | address | phone |
+--------+-------+-------+------------------+---------+
| 1 | steve | 100 | 5th cross street | 2456987 |
| 2 | david | 98 | welling street | 547896 |
| 5 | anne | 100 | downing street | 2634821 |
| 8 | mille | 98 | victoria street | 1236547 |
+--------+-------+-------+------------------+---------+
4 rows in set (0.05 sec)
|