php
MySQL WHERE Clause
The WHERE clause is used to extract only those records that fulfill a specified condition.
Syntax

SELECT column_name FROM table_name WHERE column_name operator value

The SQL query using the WHERE clause in SELECT statement, after that we'll execute this query through passing it to the PHP mysqli_query() function to get the filtered data.

You can use one or more tables separated by comma to include various conditions using a WHERE clause, but WHERE clause is an optional part of SELECT command.

You can specify more than one conditions using AND or OR operators.

A WHERE clause can be used along with DELETE or UPDATE SQL command also to specify a condition.

The WHERE clause works like an if condition in any programming language. This clause is used to compare given value with the field value available in MySQLi table.

idNameCollegeEmail IdMobile
1V V Ramana ReddyS V Arts and Science Collegeinfo@freetimelearning.com9963666068
2ChantiVidhyalaya Degree Collegefreetimelearn@gmail.com9010023210
3RamanaS V Universityvvramanareddy9963@gmail.com9966463846
4SureshAadhishankarasureshreddy@gmail.com9700900292
5Suman ReddyPriyadharshinisumanreddy.mca@gmail.com9966395199

The following example will return all the records from student_details_2 table for which stu_name is Chanti :

<?php

	$ftl_connect = mysqli_connect("localhost", "root", "", "ftl_db");
	 
	// Check connection
	if($ftl_connect === false){
		die("ERROR: Could not connect. " . mysqli_connect_error());
	}
	 
	// Attempt select query execution
	$sql = "SELECT * FROM student_details_2 WHERE stu_name='Chanti'";
	if($result = mysqli_query($ftl_connect, $sql)){
		if(mysqli_num_rows($result) > 0){
			echo "<table class='table table-bordered'>";
				echo "<tr>";
					echo "<th>id</th>";
					echo "<th>Name</th>";
					echo "<th>College</th>";
					echo "<th>Email Id</th>";
					echo "<th>Mobile</th>";
				echo "</tr>";
			while($row = mysqli_fetch_array($result)){
				echo "<tr>";
					echo "<td>" . $row['stu_id'] . "</td>";
					echo "<td>" . $row['stu_name'] . "</td>";
					echo "<td>" . $row['college'] . "</td>";
					echo "<td>" . $row['email'] . "</td>";
					echo "<td>" . $row['mobile'] . "</td>";
				echo "</tr>";
			}
			echo "</table>";
			// Close result set
			mysqli_free_result($result);
		} else{
			echo "No records matching your query.";
		}
	} else{
		echo "Error - could not able to execute $sql. " . mysqli_error($ftl_connect);
	}
	 
	// Close connection
	mysqli_close($ftl_connect);

?>
Output :
idNameCollegeEmail IdMobile
2ChantiVidhyalaya Degree Collegefreetimelearn@gmail.com9010023210