How to use where clause in MySQL through PHP

In this article I am going to explain about MySQL where clause.
  • 2133

WHERE Clause in PHP MySQL

In MySQL where clause gives the criteria for the row to be selected or you say that where clause specifies the conditions that must be met for a row to be included in the result set. The search condition of a where clause consists of one or more boolean expression that result in a true, false or null value.

Syntax of where clause

SELECT columnName from table name WHERE ColumnName(=,<=,>=,! or any operator) value

Example of where clause

<html>

<body>

<?php

$con = mysql_connect("localhost","gupta","sharad");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("Mcn_Solution", $con);

 

$result = mysql_query("SELECT * FROM Emp where LastName='singh'");

 

while($row = mysql_fetch_array($result))

  {

  echo $row['Fname'] . " " . $row['LastName'];

  echo "<br />";

  }

 

mysql_close($con);

?>

</body>

</html>


Output:

update php.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.